Nice way to animate when the flash button is pressed

This may be obvious, but it's been a long time since I used flash. I have an object drawn in flash, say a clock. When the clock is pressed, I want to revive the hands that revolve around.

So, I create a clock as a button and call the animation in a down state? Or is it better to create a clip and make it act like a button? Atm I use listeners to listen for clicks on an object and jump to its animation in the main timeline. If I have a lot of objects, the main timeline will be huge, so I need a good way to do everything in the movie clips, but I can still click them. I am using CS4 AS3

thank

+2


source to share


2 answers


Make it MovieClip. Let's say your instance name for the clock is "mcClock". Since we are targeting a target, you can use the same function handler for all of your clips.



mcClock.addEventListener(MouseEvent.CLICK, handleClickOnObject);
mcClock.buttonMode = true; //to display hand cursor
//easily use the same functon for another MovieClip
mcClock2.addEventListener(MouseEvent.CLICK, handleClickOnObject);

function handleClickOnObject(e:MouseEvent):void
{
     e.target.play(); 
}

      

+2


source


I would say that different MovieClips for a different state would be better, as you may need some other states (Disabled, Hovered, Clicked, etc.). Different MovieClips in different states will also help you organize your code, and it will be much easier to change individual MovieClip states rather than inserting and removing multiple frames in the timeline.

So my suggestion



-Make a standard or custom button -Show different MovieClips for different states (either you change them to an event listener, or a default button, set a timeline) -Add animations in these separate state clips.

You could also reuse the same animation for multiple buttons this way.

-1


source







All Articles