Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Hover script not working in animation AS3

Community Beginner ,
Aug 09, 2017 Aug 09, 2017

Hye guys,

This is a continuous thread ofButton Hover​.

After applying code form just.emma​ i tried to make some animation for the buttons.

the problem come after the button animation stop, the button hover is not working.

here is the .fla file : Dropbox - Adobe Animate CC

I have made two(2) buttons, 1 is static that hover is working & another 1 is with animation that hover not working.

Kindly help me inspect what is the problem.

Thank you.

288
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Contributor , Aug 10, 2017 Aug 10, 2017

The code you have written for all the buttons run as soon as you start playing, but the button that the code is trying to access, does not exist at that point. So one way to fix this would be to keep each of the buttons off screen at the start. Another way to solve it would be to execute the code once all buttons are on the screen, but I would recommend the first solution.

Also, here's one way you could write the code, to make it a lot less repetetive:

function CreateButton (_button : DisplayObjec

...
Translate
Contributor ,
Aug 10, 2017 Aug 10, 2017
LATEST

The code you have written for all the buttons run as soon as you start playing, but the button that the code is trying to access, does not exist at that point. So one way to fix this would be to keep each of the buttons off screen at the start. Another way to solve it would be to execute the code once all buttons are on the screen, but I would recommend the first solution.

Also, here's one way you could write the code, to make it a lot less repetetive:

function CreateButton (_button : DisplayObject, _animation : MovieClip) {

     var over : Function = function () {

          _animation.gotoAndPlay("animate");

     }

     var out : Function = function () {

          _animation.gotoAndStop(1);

     }

     _button.addEventListener(MouseEvent.MOUSE_OVER, over);

     _button.addEventListener(MouseEvent.MOUSE_OUT, out);

}

CreateButton(subMenuStatic_mc.glass_btn, this.glassdept_mc);

CreateButton(subMenuAnimate_btn.glass_btn2, this.glassdept_mc);

That way you only have to write one line of code for each new button you want to add. And if you want to change the behaviours of the buttons, you only need to change it inside the CreateButton function, instead of on multiple different lines of code.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines