AS: Main
Ok, I dont know if this has been done before but if not, I will explain it to the best of my knowledge.
What you will be learning
In this tutorial, you will learn about the stop() code, the play() code, stopAllSounds, and how to make a menu such as play, pause, rewind, fastforward, etc.
So let's get started!
I will be breaking this topic up into sections and the first section will explain stop() and play().
------------------
Stop and Play
Okay, stop() and play() are probably the most important codes in flash. To use the stop code, you must have the frame highlighted that you want the code on. Then, input the following code into the frame selected:
stop();
Now, test your movie and you will see that flash will stop at that frame unless told otherwise. The stop code is very good for frames with buttons such as the last frame of the movie with a replay button. Then next important code is play(). This is useful to use in commands such as _root.play(); (_root represents the main timeline), or on hitTests. I havent found the use of play(); all by itself. Anyways, the exat code for play is:
play();
Put that code on the frame you want to play. (You do not need to put that on every frame to play).
------------------
I think I explained that better than needed. Now you will learn about the stopAllSounds command.
------------------
The stopAllSounds command
This code is very simple. If you want a frame to stop very sound being played, put this code on the frames actions:
stopAllSounds();
Again, you can also use _root if you are placing it inside a MC. And for a button, you could do this code:
on(press) {
stopAllSounds();
}
That will stop every sound on the main timeline.
------------------
Now, since that is all done, you will learn how to make a menu that has these commands:
Subtitle toggling
Play Button
Stop Button
Next Frame Button
Previous Frame Button
There will be one big category for this, and than sub-categories.
------------------
Movie Control Menu
Play Button
Ok, to make a play button, all you need to do is make what you want your button, convert it to a button, than give it these actions:
on(press) {
_root.play();
}
That wasn't hard, was it? Thats tells flash to play the movie when the button is pressed.
------------------
Stop Button
Ok, now you will learn how to make a stop button. This is also very simple. Make what you want your stop button, convert it to a button, then give it this code:
on(press) {
_root.stop();
}
Yay! You are almost done with your menu! The way the code works is it tells flash to stop the movie when the button is pressed. The rest of the codes arent hard either so lets move on!
------------------
Forward Button
Again, another easy code. Make what you want your button, convert it to a button, then give it this code:
on(press) {
_root.nextFrame();
}
That didnt kill you, did it? The way that works, is it tells flash to toggle through the frames when the button is pressed. The last button code is on its way!
------------------
Backwards Button
Simple, create what you want your button, convert it to a button, then give it this code:
on(press) {
_root.prevFrame();
}
Done. The way that works is it tells flash to toggle through the previous frames when the button is pressed. The last bit of this tutorial is optional for if your movie has voice actiing.
------------------
Subtitle Toggling
This gets pretty complicated. Ok, the way to do this code requires more then just one AS code so bear with me. First, create your subtitles and put them all into one MC and give it the instance name of "subtitles" without the quotes. Then, make the toggling button and paste this code onto it:
on(press) {
if(_root.subtitles._visible==true)) {
_root.subtitles._visible=false;
}
on(press) {
if(_root.subtitles._visible==false)) {
_root.subtitles._visible=true;
}
There ya go! You got a full working menu. I think I explained this tutorial pretty well so have fun with it! And, report anything that doesnt work!