PDA

View Full Version : nextFrame prevFrame Continious Play



highaflash
December 11th, 2009, 05:34 PM
Hello,
First off, I'm a total noob when it comes to actionscript. I'm attempting to create a flash movie file that basically has a number of thumbnails in a straight line. As the user puts their mouse over a button I'd like the movie to advance to the next frame and keep playing until the user's mouse leaves that button. I found an online tutorial to accomplish this in AS 2.0 but I would rather do it in 3.0 so it's current.

I have the following code that sort of works; when I hover over the right_btn, it advances to the next frame, but only advances 1 frame instead of playing the movie forward. The left_btn should go to the previous frame and play the movie backwards.

right_btn.addEventListener(
MouseEvent.MOUSE_OVER,
function(evt:MouseEvent):void {
nextFrame();
}
);
left_btn.addEventListener(
MouseEvent.MOUSE_OVER,
function(evt:MouseEvent):void {
prevFrame();
}
);

Any help you guys can lend would be greatly appreciated.

Scythe
December 11th, 2009, 07:46 PM
As for making something play forwards, just use play() instead of nextFrame(), but there's no automatic way to make a movieclip play backwards. Knowing almost nothing about what you're trying to accomplish, I don't know what to suggest. Do you want the button to play backwards? A separate movieclip? The whole SWF? If it's the parent of the button you want to play, I certainly hope the button's still there in the other frames.

The most basic way to accomplish this is to have two animations, the forward version and the backward version. If that's not an option or you wanna save space you could have prevFrame in an ENTER_FRAME event listener. Also if the animation is simple enough you can ditch the timeline altogether and just use the Tween class: http://help.adobe.com/en_US/AS3LCR/Flash_10.0/fl/transitions/Tween.html (http://help.adobe.com/en_US/AS3LCR/Flash_10.0/fl/transitions/Tween.html)