2
votes

This may be obvious but it's been ages since I used flash. I have an object drawn in flash lets say a clock. When the clock is clicked I want to animate the hands spinning round.

So do I create the clock as a button and call the animation on the down state? Or is it better to create a movie clip and have it act like a button? Atm I'm using listeners to listen for clicks on objects and navigate to its animation in the main timeline. If I have many objects the main timeline is going to get huge so I need a good way to make everything into movieclips but still be able to click them. I'm using CS4 AS3

Thanks

2

2 Answers

2
votes

Make it a MovieClip. Lets say your instance name for the clock is "mcClock". Since we access the target you can use the same function handler for all your MovieClips.

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(); 
}
-1
votes

I would say different MovieClips for different state will be better as you might want need some other states also(Disabled, Hovered, Clicked etc...). Different MovieClip on different state would also help you your code organized and will be much easier to modify individual MovieClip of states rather than inserting and deleting multiple frames in timeline.

So, My suggestion is

-Make standard or Custom Button -Put different MovieClips for Different states(either you swap them on event listener or If default Button, put on timeline) -Add animation in those separate State MovieClips.

You would also reuse same animation for multiple button effectively by this way.