Forum Topic: AS: Movie Control

(2,504 views • 12 replies)

This topic is 1 page long.

<< < > >>
None

SpamBurger

Reply To Post Reply & Quote

Posted at: 7/26/05 07:27 PM

SpamBurger NEUTRAL LEVEL 15

Sign-Up: 07/12/05

Posts: 4,747

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!

"However, the game received only two orders, one of which Molyneux speculated was from his mother." -Peter Molyneux's first game The Entrepreneur


None

Inglor

Reply To Post Reply & Quote

Posted at: 7/26/05 07:43 PM

Inglor NEUTRAL LEVEL 17

Sign-Up: 01/26/03

Posts: 10,948

Very useful though most of it is already covered in as replay button or in as stop and play buttons


None

SpamBurger

Reply To Post Reply & Quote

Posted at: 7/26/05 07:44 PM

SpamBurger NEUTRAL LEVEL 15

Sign-Up: 07/12/05

Posts: 4,747

Denvish, I never knew those codes existed! Cool!

"However, the game received only two orders, one of which Molyneux speculated was from his mother." -Peter Molyneux's first game The Entrepreneur


None

Denvish

Reply To Post Reply & Quote

Posted at: 7/26/05 07:45 PM

Denvish DARK LEVEL 46

Sign-Up: 04/25/03

Posts: 16,229

I think a better way of doing the fforward and rewind buttons is like this, it means you can hold them down, rather than repeatedly clicking

FFWD button:

on(press){
_root.ffwd=1;
}
on(rollOver, rollOut, dragOut){
_root.ffwd=0;
}

REWIND button:

on(press){
_root.rwnd=1;
}
on(rollOver, rollOut, dragOut){
_root.rwnd=0;
}

on main timeline, first frame

_root.onEnterFrame= function(){
if(ffwd){ gotoAndPlay (_currentframe+5); }
if(rwnd){ gotoAndPlay (_currentframe-5); }
}

and... a public fla for anyone who wants to have a play (simplicity not guaranteed)

- - Flash - Music - Images - -

BBS Signature

None

SpamBurger

Reply To Post Reply & Quote

Posted at: 7/26/05 07:46 PM

SpamBurger NEUTRAL LEVEL 15

Sign-Up: 07/12/05

Posts: 4,747

Denvish, why do you always delete your posts?!

"However, the game received only two orders, one of which Molyneux speculated was from his mother." -Peter Molyneux's first game The Entrepreneur


None

Denvish

Reply To Post Reply & Quote

Posted at: 7/26/05 07:47 PM

Denvish DARK LEVEL 46

Sign-Up: 04/25/03

Posts: 16,229

At 7/26/05 07:46 PM, SpamBurger wrote: Denvish, why do you always delete your posts?!

Because I can, and I forgot the link

- - Flash - Music - Images - -

BBS Signature

None

SpamBurger

Reply To Post Reply & Quote

Posted at: 7/26/05 07:48 PM

SpamBurger NEUTRAL LEVEL 15

Sign-Up: 07/12/05

Posts: 4,747

At 7/26/05 07:47 PM, Denvish wrote:
At 7/26/05 07:46 PM, SpamBurger wrote: Denvish, why do you always delete your posts?!
Because I can, and I forgot the link

Lol, its funny how, in my stop and drag thread, you posted some weird shit and deleted it.

"However, the game received only two orders, one of which Molyneux speculated was from his mother." -Peter Molyneux's first game The Entrepreneur


None

gorman2001

Reply To Post Reply & Quote

Posted at: 7/26/05 07:51 PM

gorman2001 NEUTRAL LEVEL 14

Sign-Up: 08/18/02

Posts: 1,933

nice job SpamBurger. u answered a lot of noob's questions here.


None

SpamBurger

Reply To Post Reply & Quote

Posted at: 7/26/05 08:30 PM

SpamBurger NEUTRAL LEVEL 15

Sign-Up: 07/12/05

Posts: 4,747

At 7/26/05 07:51 PM, gorman2001 wrote: nice job SpamBurger. u answered a lot of noob's questions here.

Thanks.

"However, the game received only two orders, one of which Molyneux speculated was from his mother." -Peter Molyneux's first game The Entrepreneur


None

JimmyDodger

Reply To Post Reply & Quote

Posted at: 2/16/06 06:29 AM

JimmyDodger EVIL LEVEL 15

Sign-Up: 11/27/05

Posts: 2,684

Awesome dude! Really helped me out!

Brawl: 2621-4093-5273
Email: el-grosso@hotmail.co.uk

BBS Signature

None

ZYX3D

Reply To Post Reply & Quote

Posted at: 2/16/06 06:47 AM

ZYX3D DARK LEVEL 21

Sign-Up: 07/31/04

Posts: 437

At 7/26/05 07:27 PM, SpamBurger wrote: (...)
------------------
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;
}

Why not just:

on(press){_root.subtitles._visible= !_root.subtitles._visible;}

since _visible is a Boolean? Works just the same, more optimized code...


None

Shizaam

Reply To Post Reply & Quote

Posted at: 4/12/06 12:37 AM

Shizaam EVIL LEVEL 08

Sign-Up: 10/25/05

Posts: 320

Sweet, that was awesome, really helped


None

AzVortez

Reply To Post Reply & Quote

Posted at: 10/30/06 08:07 PM

AzVortez NEUTRAL LEVEL 11

Sign-Up: 10/22/05

Posts: 52

great, u hav the stopallsound command. whats the one to play all sounds?

like if im playin music on frame 1-200, i stop all sounds on frame 13, and then wanna start all of them (music) on frame 79, what AS command is that?


All times are Eastern Standard Time (GMT -5) | Current Time: 02:25 AM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!