Flash AS3 - How do I create a button that animates on 'mouseover' and animates back on 'mouseout'?

keybord
keybord used Ask the Experts™
on
I am learning Flash AS3  and would like to create a button that is a little more complex than the standard four-state symbol.

I would like the understand the relevant code required to animate a button when I mouse over it and then animate back when I mouse out.  

I intend to use a sort of 'key pressing' animation and can create movieclips for the in and out animations (which will not be exactly the same) but dont know how to pull everthing together into a working button.

I can supply and .fla file if it would be more meaningful / helpful.

Thank you very much in advance for your time and assistance!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
You can do it with buutons and Movieclip ..

if you will use buttons just make  you button with the 4 states and make 2 mvie clip with the animation yopu want and put those movieclips in the OVER and OUT states of ur buttons ... this way this anaimation will play when mouse over or nouse out

i think it will be better if u use a movie clip instade of button this will give you more controll

best regards

Author

Commented:
Thanks,

As I mentioned I am familiar with the button option...If I use movie clips what is the AS3 code I will need to control the mouseover / mouseout states?  Is there an existing example of the code or something I might use as a template?

Commented:
try this code


best regards





my_mc.buttonMode = true;
my_mc.addEventListener(MouseEvent.MOUSE_OVER, myOver);
my_mc.addEventListener(MouseEvent.MOUSE_OUT, myOut);
 
 
function myOver(event:MouseEvent):void{
	my_mc.gotoAndPlay(2);
	}
function myOut(event:MouseEvent):void{
	my_mc.gotoAndPlay(2);
	}

Open in new window

Should you be charging more for IT Services?

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Commented:
the last line was wrong .... here is the right code again
the code above use action script 3 with flash CS3 .....

you creat a movie clip called my_mc and added 2 actions for it as you see and made 2 functions  ... a functione for mouse over and onther for mouse out

and this is live example :

http://rapidshare.com/files/85618171/overout.zip.html

best regards
my_mc.buttonMode = true;
my_mc.addEventListener(MouseEvent.MOUSE_OVER, myOver);
my_mc.addEventListener(MouseEvent.MOUSE_OUT, myOut);
 
 
function myOver(event:MouseEvent):void{
	my_mc.gotoAndPlay(2);
	}
function myOut(event:MouseEvent):void{
	my_mc.gotoAndPlay(16);
	}

Open in new window

Author

Commented:
thanks, thats looking good - out of time at the moment but will have a look at it properly later this afternoon.

Author

Commented:
Couldn't resist a quick look.

Exactly what I was looking for!  

Many thanks FLAASHER - I suspect you may be hearing from me again...

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start Today