Skip to main content
Participating Frequently
April 27, 2021
Question

set movie clip visibility to false

  • April 27, 2021
  • 1 reply
  • 1634 views

I have been using Flash and CS3 for years and am now trying to get into Animate CC coding using HTML5 Canvas.

I have a simple movie clips dropping from the top of the screen and wanting to hide (visible=false) on mouse over.

Use the following code to loop through an array of objects set up as

var myCoins = [this.coin1, this.coin2 etc....]

for (i = 0; i < 6; i++){
myObj=myCoins[i];
myCoins[i].addEventListener("mouseover", function () {
$myCoins[i].style.visability=hidden;
}//end function

)//end listener

}//end loop

    This topic has been closed for replies.

    1 reply

    Participating Frequently
    April 27, 2021

    my bad the code i am using is as follows - please ignore my previous code as this was my mad testing and playing 

     

    for (i = 0; i < 6; i++){
            myCoins[i].addEventListener("mouseover", function () {
                    $myCoins[i].visible=false;
            }//end function
    )}//end loop

    CodeDeveloperOM
    Inspiring
    April 27, 2021

    this.,,,,,,,,,.addEventListener("mouseover", fl_mouseover.bind(this));
    function fl_mouseover(evt) {

      this.myCoins[i].visible=false;
    }

    Participating Frequently
    April 29, 2021

    Thank-you but this didn't work.

    I tried the following code within my for loop instead of my code from above

    this.myCoins.addEventListener("mouseover", fl_mouseover.bind(this));

    function fl_mouseover(evt) {

      this.myCoins[i].visible=false;
    }

    Error Message: Uncaught TypeError: Cannot read property 'addEventListener' of undefined

    I am trying set the eventListener for mouseover on each object in my array.

    I have been able work through the array to make the items appear in random positions and scroll down the screen.