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

Hover/click button change

Community Beginner ,
Mar 09, 2023 Mar 09, 2023

Copy link to clipboard

Copied

Hello, I am trying to code a button so that when the mouse hovers over, it changes color, and then when you click it changes again. 

 

Right now I have the button built with three frames, but when I do the test animation and hover over the button it only flashes for an instance. When I click it flashes the three frames, but what I'd like is for it to click and hold on the third frame. The button is called "upgrade_now" - any help or guidance on the code for this would be appreciated. 

 

Thanks!

Views

271

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 Expert ,
Mar 09, 2023 Mar 09, 2023

Copy link to clipboard

Copied

you need to use a movieclip and code it to respond to the mouse.

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 ,
Mar 09, 2023 Mar 09, 2023

Copy link to clipboard

Copied

Hey, thanks again for your help. Right now I am trying to get the movieclip to click and hold on frame 3, and have the code written as follows: 

 

movieclipname.addEventListener(MouseEvent.CLICK,clickF);

 

function clickF(e:MouseEvent):void{

gotoAndStop(3);

}

 

But I am still running into the issue of it just causing the movieclip to play and loop to frame 1. The action script is set on the main timeline, and starts when the movie clip appears. I have yet to figure out how to get the movie clip to respond and pause on frame 2 with just a hover over action.

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 Expert ,
Mar 09, 2023 Mar 09, 2023

Copy link to clipboard

Copied

LATEST

you should use frame labels.  it's easier to debug and edit.

 

moveclipname.addEventListener(MouseEvent.MOUSE_OVER,overF);

movieclipname.addEventListener(MouseEvent.MOUSE_OUT.outF);

movieclipname.addEventListener(MouseEvent.CLICK,clickF);

 

function overF(e:MouseEvent):void{

e.currentTarget.gotoAndStop("overframe");

}

function outF(e:MouseEvent):void{

e.currentTarget.gotoAndStop("upframe");

}

function clickF(e:MouseEvent):void{

e.currentTarget.gotoAndStop("clickedframe";  // you may want to remove your mouseout listener here

this.gotoAndStop(3); //if you're trying to direct the parent of movieclipname to its frame 3.

}

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