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

Button Hover

Community Beginner ,
Aug 08, 2017 Aug 08, 2017

Copy link to clipboard

Copied

Hi,

Really need a help.

I have Button name btnSub (instance : btnSub_btn) inside MovieClip named btnMain_mc (instance : btnMain)

and I want it to play label "animate" in MovieClip named hover_mc (instance name hover) when mouse over on btnSub.

Thank you.

cc. Colin Holgate

.fla file : http://pixelsbooth.my/public/hover_test.fla

Views

3.1K

Translate

Translate

Report

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

Advocate , Aug 08, 2017 Aug 08, 2017

Since you're working in AS3, you should use:

btnMain.btnSub_btn.addEventListener(MouseEvent.MOUSE_OVER, over);

function over(event:MouseEvent):void

{

this.hover.gotoAndPlay("animate");

}

If you were working in HTML5 Canvas (which is better long term since Adobe is discontinuing the Flash Player in the next few years), it would look like:

stage.enableMouseOver();

this.btnMain.btnSub_btn.addEventListener("mouseover", over.bind(this));

function over()

{

  this.hover.gotoAndPlay("animate");

}

For future referenc

...

Votes

Translate

Translate
LEGEND ,
Aug 08, 2017 Aug 08, 2017

Copy link to clipboard

Copied

So... put the movieclip you want to play in the over state frame of the button. That's what it's there for.

Votes

Translate

Translate

Report

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
Community Beginner ,
Aug 08, 2017 Aug 08, 2017

Copy link to clipboard

Copied

Hye there thank for the reply,

i have done it, but the hover respond is slow,

there some kind of delay after the second hover if do it fast.

test it here please hover_test

Thank you.

Votes

Translate

Translate

Report

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
Advocate ,
Aug 08, 2017 Aug 08, 2017

Copy link to clipboard

Copied

Since you're working in AS3, you should use:

btnMain.btnSub_btn.addEventListener(MouseEvent.MOUSE_OVER, over);

function over(event:MouseEvent):void

{

this.hover.gotoAndPlay("animate");

}

If you were working in HTML5 Canvas (which is better long term since Adobe is discontinuing the Flash Player in the next few years), it would look like:

stage.enableMouseOver();

this.btnMain.btnSub_btn.addEventListener("mouseover", over.bind(this));

function over()

{

  this.hover.gotoAndPlay("animate");

}

For future reference, from Animate you can go to Window > Code Snippets to find examples of simple scripts like these.

Votes

Translate

Translate

Report

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
Community Beginner ,
Aug 09, 2017 Aug 09, 2017

Copy link to clipboard

Copied

Hye just.emma,

Thanks for ur time.

I've put it in timeline then got below msg:

ArgumentError: Error #2109: Frame label animate not found in scene animate.

at flash.display::MovieClip/gotoAndPlay()

at hover_test_Scene1_fla::MainTimeline/over()

Votes

Translate

Translate

Report

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
Advocate ,
Aug 09, 2017 Aug 09, 2017

Copy link to clipboard

Copied

It worked fine when I tested it: Dropbox - hover_test_iezqandarzulqarnaen

Votes

Translate

Translate

Report

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
Community Beginner ,
Aug 09, 2017 Aug 09, 2017

Copy link to clipboard

Copied

LATEST

Hye guys,

Thanks to just.emma​ for solution with flying colors ~

I tried it before but not work it is because I've deleted the animation frame & forgot to undo that's why, nothing wrong with her codes.

also thanks to RandomlyFish​ & ClayUUID​ for tying to help but I cant understand due to my limit in this AS3 knowledge (1 month), thank you by the way.

see you later with questions of course.

Votes

Translate

Translate

Report

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
Contributor ,
Aug 09, 2017 Aug 09, 2017

Copy link to clipboard

Copied

When I try your example, it seems like the animation doesn't play every other time you move the mouse over the button. Though I notice that when the animation doesn't play, it looks like a slightly bigger square appear, so it seems like the hover animation is stuck on some frame.

you could try to find out what frame the hover movieclip is currently on after you call gotoAndPlay, using "hover_mc.currentFrame". If you don't get the same result every time, then something is wrong with the playback.

I got it to work with a button and hover effect as separate symbols on the stage, with this code:

var button = this.Button;

var hover = this.Hover;

stage.enableMouseOver();

button.addEventListener("mouseover", ButtonHover);

function ButtonHover () {

    hover.gotoAndPlay("animate");

}

I also got it to work by placing a movieclip with an animation on the over frame inside a button. For that you don't need to trigger the movieclip to play, you just need to add "this.stop();" to the last frame of the animated movieclip if you don't want it to loop.

Votes

Translate

Translate

Report

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