views:

55

answers:

3

I'm having a problem with a small animation for a form I'm creating in flash. Basically I want the motion to happen when I click it, and then stop where its told to. It plays and stops just fine, however I cannot figure out how to make it wait for the click to play. This is the current code I have

tabbut.onClick = function() { play(); }

i have also tried the MouseEvent method, but that makes it keep looping.

any suggestions would be greatly appreciated.

A: 

If you're using the main timeline, you need to put a stop(); action on the first frame.

If your animation is inside a MovieClip (which is recommended), then use the following:

myClip.stop();
Soviut
+1  A: 

i have also tried the MouseEvent method, but that makes it keep looping.

This is the correct approach. play() will play and loop. If you need finer control on the playback, I suggest adding a listener to enterframe event and doing the required logic there.

    // Play when clicked
myMovieClip.addEventListener("click", function(event:MouseEvent) {
    play();
});
    // Stop when arrived on last frame
    // This could be replaced by inline frame code on the last frame
myMovieClip.addEventListener("enterframe", function(event:Event) {
    if(currentFrame == totalFrames)
        stop();
});
LiraNuna
thank you for your advice! the animation still automatically plays when the form is loaded, but now when it stops i can click on it and it replays.i need the movement to not start UNTIL it is clicked.
jxd215
OH i fixed it. I forgot to add the stop action in the first frame >.< thank you very much for your help!
jxd215
No problem, feel free to select this as the accepted solution :)
LiraNuna
Done! Thanks again :)
jxd215
A: 

have implemented your animation with code or in a movie clip timeline? if you have a movie clip timeline, insert a stop(); statement in the first frame of the movie clip code.

farzad