Since it comes up a lot, I'm going to cover animation flow here, basically answering the questions of how to make a loop, and how to make buttons. The following describes how to do this in ActionScript 2.0 since that's what most people will be using as they learn Flash, I'll post again with ActionScript 3.0 code later on, and when v0.3 eventually comes out we'll write a tutorial on how to do looping etc. in that.
Creating smooth loopsI'm assuming here that you already have most of your animation done, but it's worth noting how to create nice smooth loops. To create a loop you need a section of your animation that starts and ends the same. The easiest way to achieve this is to copy the "column" of frames at the start of your loop (select them, right-click then choose "copy frames") then paste them at the end by selecting the "column" of frames at the end then right-clicking and choosing "paste frames". To create a truly smooth loop your loop should actually loop one frame before the newly pasted frames, otherwise you may get the same frame twice resulting in a brief pause.
Making loopsNow, to begin with it's a good idea to create a new layer for organising your animation, just add a new layer as normal, then create a key-frame at the start of each section of your animation. Clicking on these keyframes, look in the properties window and give them a unique name. It's generally good practise to name all important sections of your animation, even if you don't intend to loop them, as you can add back buttons to skip back to them if you like. You should end up with your timeline looking something like this:
- Timeline with names
- Timeline 1.png (37.32 KiB) Viewed 56855 times
Now, using names is optional, but it makes it much easier to organise your animation, and you can also use them when jumping around within the animation to make things much easier, the code we're interested in is this:
- Code: Select All Code
gotoAndPlay("name");
This line tells Flash to jump to the frame named "name" and begin playing from there, you can also use gotoAndStop("name") if you don't wish the animation to continue playing after the jump.
To add a loop, we need to add some more keyframes at the end of each looping section, and insert the gotoAndPlay("name") code into them. To do this, simply add the keyframes, then select each one and open the actions window, then type in the gotoAndPlay("name") line, replacing "name" with the named frame you wish to jump to. In the example picture we would add gotoAndPlay("fuck") to frame number 21, and gotoAndPlay("hard") to frame number 31, giving us two looping sections. Now when our animation plays it will enter the "fuck" loop and loop forever (as it has no way to skip ahead yet). At this stage you may also like to add a keyframe at the very end, and add the following command into it:
- Code: Select All Code
stop();
As this will stop the animation when it reaches the end. You could also add a looping section at the end if you wish, but in this example I'll just have it stop. Your timeline should now look something like this:
- Timeline with scripted looping
- Timeline 2.png (32.13 KiB) Viewed 56855 times
Adding buttonsSo now we have a looping animation, but we need some way to exit the loops and move forwards! To do this we will add buttons. Create yourself a new layer to put the buttons on, create a keyframe in your first loop and throw the buttons somewhere into the scene. In my example I'll just add a single button to the "fuck" loop so I can proceed to the "hard" loop.
Simply select your button and open the actions window. Now, we want to add our friend the gotoAndPlay() function to this button, but we need a little extra code to describe when to do this, in our case we will use the on(release) event, which simply means to perform the jump once the user lets go of their mouse button. Add the following code to your button using the actions window:
- Code: Select All Code
on(release) {
gotoAndPlay("name");
}
Replacing of course "name" with the appropriate named frame to jump to. During the "fuck" loop I would add gotoAndPlay("hard"). You can now add buttons to your other loops in the same way by adding new keyframes, buttons, and code as normal.
Your animation should now be interactive, and your timeline will look like this:
- Time with scripted buttons
- Timeline 3.png (39.25 KiB) Viewed 56855 times
In this example we might add a forward button to the "fuck" loop that jumps to "hard", then two buttons in the "hard" loop, one going back to "fuck", and one going forward to "cum". The "cum" section will then have a single back button jumping back to "hard".
We could optionally add a back button the "fuck" loop, and an "again" or "all done" button to the "cum" section which use gotoAndPlay(1) to jump back to the start of the animation, in that case we might want to name the first frame for clarity.