paulCardiff
asked on
How do I use conditional statements to play motion tween?
I have made a flash movie and want the script to navigate one frame at a time but instead of going to nextFrame(); I want it to play the next frame which is a motion tween, and have the ability to go back and forth just like a static slide show
The code I have so far is below:
I think I need to replace prevFrame(); and nextFrame(); with different script
The code I have so far is below:
I think I need to replace prevFrame(); and nextFrame(); with different script
stop();
function goBack(event:MouseEvent):void
{
if(currentFrame == 1)
{
gotoAndStop(totalFrames);
}
else
{
prevFrame();
}
}
function goForward(event:MouseEvent):void
{
if(currentFrame == totalFrames)
{
gotoAndStop(1);
}
else
{
nextFrame();
}
}
back_btn.addEventListener(MouseEvent.CLICK, goBack);
next_btn.addEventListener(MouseEvent.CLICK, goForward);
ASKER
Thanks for the feedback.
The tween is evenly spread out, user goes from frame 1-20 (as one click of mouse), then 21-40 on next click. I'm not too worried about them being able to stop the motion tween in the middle, just so long as the user can go back and forth. So, you could keep looping one way round as much as you want, but if the user wants to go back then they have that option.
I've tried the mouse up event but i get the same problem, it just goes to the next frame, and does not play the tween.
The tween is evenly spread out, user goes from frame 1-20 (as one click of mouse), then 21-40 on next click. I'm not too worried about them being able to stop the motion tween in the middle, just so long as the user can go back and forth. So, you could keep looping one way round as much as you want, but if the user wants to go back then they have that option.
I've tried the mouse up event but i get the same problem, it just goes to the next frame, and does not play the tween.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
on the timeline i have 4 frames then a tween from 4 to 10 then another tween from 10 to 20
1234--------10-----------2
so you would want the user to go from 1 to 2 to 3 to 4 to 10 to 20 by clicking next and then reversing this process if the prev button is pressed? Added to this be able to stop the motion tween somewhere in the middle and go back and forth?
it seems that what you have should work, i guess you could use the mouse down event to keep playing as long as user has the button depressed on the mouse and on mouse up stop playing