Make a image blink

Hello first, I need to know if I can modify the examples given in this forum, I just download one of the examples from Making Rectangle Flash -Easiest Way?.
If yes, I am trying to make the image “red” blink when the button is pressed and stop blinking when the button is pressed again.
I try to modify javascript but I could not get the result I need. Any help is more than welcome.


If the projects are posted as examples on how to do something then yes.

There are some caveats. There may be media, images, sounds, video included that are only used for example purposes and in many cases should not be used for commercial or the wider web (including personal use) etc with out the copyright holders permission.

Most code we post up is being put up in the knowledge that we are putting it here for reuse or to be altered.

If you see that someone has only posted a project so they can get help with it then think twice and ask before you use any of the materials. In many cases these should only be projects that they are happy with people seeing and probably using items but not all, so IMO it is best to try to distinguish these and ask for permission if you want to use something from them. Code or ideas that we offer to enhance them should not be a problem. Remember I am mainly talking about included media.

So from what I see in the link there should not be a problem you using and altering said project.

1 Like

Thanks for the info Mark, I am using your example reply in that post.
Do you have an idea on how to make this work?

There are a few ways to achieve what you are trying to do.

The example you have chosen is a little complex because it needs other behaviours.

If I was to keep to using JS I would do something like this…

 if (! window.theTimerClick  ){ 
 //--  Start blinking 
 window.theTimerClick  =true 
window.theTimer = setInterval(function(){ myTimer() }, 1000);

  } else {
   //--  Stop blinking
  window.theTimerClick  =false
function myTimer() {
 var currentElement =  hypeDocument.getElementById('foo')
 var currentCol = = =  (currentCol == "rgb(220, 33, 60)" ? "rgb(240, 240, 240)"   :"rgb(220, 33, 60)"   );


function myStopFunction() {

    clearInterval( window.theTimer);
} (13.8 KB)

1 Like

@MarkHunte Hi,
That is showing the button to blink, What I am looking for is to make the image above the button to blink (the image is white and after the button is pressed the image turn red and white until the user press the button again) the button will change the image itself after pressed, but this I already make it with the help of this forum. Thanks anyway I will use this JS for another use for sure.

in the code the button has the id of 'foo’
The code simply looks for the id ‘foo’ and act upon the element it finds with it.

Just change the image id to ‘foo’ or in the code ‘foo’ to the image id.

1 Like

@MarkHunte, what Am I doing wrong? does not work :frowning: (20.0 KB)

There is nothing you have done wrong code or id wise.
The problem is I just realised you are talking about an image.

Images are normally flat so changing the colour requires either a image change, some transparency, so back ground comes through, an overlay which changes colour or colour manipulation like hue…


Which I see I already gave you an example of image swap a short while back and you have used in your latest question

1 Like

@MarkHunte, it is almost perfect already set as solve the problem, but is there a way to make the blink stops in OFF? Right now the blinking stops in ON or OFF depending on the timing of the button pressed.It is a guess. This is a light so when the button return to off the light should be OFF as well. Thanks.