Forum Topic: As: Play And Stop Buttons

(3,553 views • 17 replies)

This topic is 1 page long.

<< < > >>
None

Inglor

Reply To Post Reply & Quote

Posted at: 7/19/05 10:07 AM

Inglor NEUTRAL LEVEL 17

Sign-Up: 01/26/03

Posts: 10,948

NOTICE: DO NOT PLACE ANY BUTTONS INSIDE A MOVIECLIP!!!

AS: Main, your no1 resource for learning AS, here on NG!

Hello, since the question has been brought up, I think it's time to make a tutorial that will cover basic frame manipulation, I am addressing and will cover

-Playing and Stopping a flash movie using stop() and play()

IF you're using scenes gotoAndStop and gotoAndPlay will give you trouble

Getting Started

First of all I'd like you to all have buttons ready, do this simple, draw something you would like as a button, and click F8 while it is selected to convert it into a button , if you wish to not go through this process click window->common libraries->buttons and drag one of those buttons into the screen

The envilope AS

All our scripts will be insite an "envilope" script, which means "trigger when the button is pressed", this tutorial will not cover that, AS: Replay button touches those, but I will just supply the envilope code, put this in the buttons actions (you can spawn that in window->development panels->actions)

put this code in the actions, make sure it says "Actions - Button", if it does not click the button, it should change:

on(release){

}

this is an event handler for "releasing the mouse over the button", it is what we'll ususally use.

we will use 2 types of actions, actions on our button and actions on the frame itself... frame actions do NOT go into our "envilope"

The very basics

place your button on some random frame in your movie, add the action play(); to it, this tells flash to play, it should now look like this:

on(release){
play();
}

now since we want the actual movie to pause, we go to that frame's actions and we alter them to

stop();

now when the movie achieves the frame with the button it should pause, when the button is clicked it will play again...

you can also do the reverse, have a "stop" button with the actions

on(release){
stop();
}

and another play button near it, this will pause the movie... pretty easy huh?

I guess it really is!

ask any questions here


None

liaaaam

Reply To Post Reply & Quote

Posted at: 7/19/05 10:18 AM

liaaaam NEUTRAL LEVEL 22

Sign-Up: 12/11/04

Posts: 14,529

To make a button to stop the movie properly (stop + goto first frame) then use this code:

on(release){
gotoAndStop(1);
}

Well, good tutorial Inglor.. very in-depth for just explaining Play and Stop. My hat goes off to you.

Now give me my hat back.

<3

None

gorman2001

Reply To Post Reply & Quote

Posted at: 7/19/05 10:20 AM

gorman2001 NEUTRAL LEVEL 14

Sign-Up: 08/18/02

Posts: 1,935

god!

when Inglor will ever stop making tutorials :P ?!?! he's on the go !


None

Inglor

Reply To Post Reply & Quote

Posted at: 7/19/05 10:21 AM

Inglor NEUTRAL LEVEL 17

Sign-Up: 01/26/03

Posts: 10,948

noes, I want to keep the hat !

keeps hat <3

well, I made a special AS: replay button too, it's in the list, denvish said that it needs to be as basic and as clear as possible, that's what I'm trying to give :)


None

Inglor

Reply To Post Reply & Quote

Posted at: 7/19/05 10:22 AM

Inglor NEUTRAL LEVEL 17

Sign-Up: 01/26/03

Posts: 10,948

At 7/19/05 10:20 AM, gorman2001 wrote: god!

when Inglor will ever stop making tutorials :P ?!?! he's on the go !

actually, I'm not really on the go, I made 15 in a week last time :P this one I made after a week of making no tutorials :P


None

CaptinChu

Reply To Post Reply & Quote

Posted at: 11/18/05 06:42 AM

CaptinChu DARK LEVEL 15

Sign-Up: 09/11/05

Posts: 3,219

I am the total noob of actionscript. I don't know how to create a button that includes stopping the sound, so that the sound doesn't loop over and create that horrible effect.

I hope you know what I'm talking about. Can you help me out?

All programming problems can be solved with Arrays!

BBS Signature

None

Sluf

Reply To Post Reply & Quote

Posted at: 11/18/05 06:44 AM

Sluf LIGHT LEVEL 08

Sign-Up: 10/18/03

Posts: 238

I think there should be a tab of tutorials before begginers called basics. Such a tutorial like this, would fit in there. Very good, and very explaining


None

Khao

Reply To Post Reply & Quote

Posted at: 11/18/05 08:05 AM

Khao EVIL LEVEL 19

Sign-Up: 09/20/03

Posts: 2,765

YAY! Now I can do actionscript! :P
Inglor loves noobs
Good job


None

GuyWithHisComp

Reply To Post Reply & Quote

Posted at: 11/18/05 11:20 AM

GuyWithHisComp LIGHT LEVEL 27

Sign-Up: 11/10/05

Posts: 4,010

At 11/18/05 06:42 AM, CaptinChu wrote: Sound thingy

I think you should post this as an own thread but since you're asking for it. Here is the AS you'll put in the button:
on(release){
stopAllSounds();
}

BBS Signature

Angry

GumSlough

Reply To Post Reply & Quote

Posted at: 3/28/06 08:25 AM

GumSlough EVIL LEVEL 04

Sign-Up: 03/23/06

Posts: 107

how do you make a mc that acts like a button and whenyou click on it it goes to a specific frame in your movie??? (I think theirs a conflict in my srcipt thats not letting me do it but I might just be getting the code wrong....any help?)


None

Inglor

Reply To Post Reply & Quote

Posted at: 3/28/06 10:13 AM

Inglor NEUTRAL LEVEL 17

Sign-Up: 01/26/03

Posts: 10,948

At 3/28/06 08:25 AM, GumSlough wrote: how do you make a mc that acts like a button and whenyou click on it it goes to a specific frame in your movie??? (I think theirs a conflict in my srcipt thats not letting me do it but I might just be getting the code wrong....any help?)

on(release){

(movieclips support on(release) events since flash mx 2004)

_root.gotoAndStop(framenumber)

if you're using scenes it is a bit messier


None

GustTheASGuy

Reply To Post Reply & Quote

Posted at: 3/28/06 10:17 AM

GustTheASGuy LIGHT LEVEL 08

Sign-Up: 11/02/05

Posts: 11,358

Nah, FlashMX is just as good, supports most of the stuff.

#ngprogramming at irc.freenode.net
haXe | Keel imperative | Spyro! | Thru you


None

DragonFruit-Rock

Reply To Post Reply & Quote

Posted at: 3/28/06 10:58 AM

DragonFruit-Rock EVIL LEVEL 13

Sign-Up: 12/31/05

Posts: 1,248

At 7/19/05 10:20 AM, gorman2001 wrote: god!

when Inglor will ever stop making tutorials :P ?!?! he's on the go !

on the contrie, thsi is one of the crapiest tutorials ever. i mean play(); and stop();!!!

If a man that always tells the truth comes up to you and says that another man always tells lies, and the man who always lies come up to you and says "I'm lying", then is he?

BBS Signature

None

Inglor

Reply To Post Reply & Quote

Posted at: 3/28/06 11:14 AM

Inglor NEUTRAL LEVEL 17

Sign-Up: 01/26/03

Posts: 10,948

At 3/28/06 10:58 AM, DragonFruit_Clock wrote: on the contrie, thsi is one of the crapiest tutorials ever. i mean play(); and stop();!!!

you only submitted 3 things to ng, all 3 tutorials, buttons and gradients... I mean buttons and gradients

buttons is just pressing f8 and marking button, gradients is clicking 'gradient' instead of 'solid' in the color toolbar...

please don't bash this tutorial as it actually helped newbies out.

Don't bother replying unless you can differ an abstract class from an interface :)


None

Toast

Reply To Post Reply & Quote

Posted at: 3/28/06 11:28 AM

Toast DARK LEVEL 09

Sign-Up: 04/02/05

Posts: 8,914

I'll have to agree with Inglor there, your tutorials aren't better. :P
Look at Inglor's other tutorials in the advanced section.


None

Pyromaniac

Reply To Post Reply & Quote

Posted at: 3/28/06 06:45 PM

Pyromaniac EVIL LEVEL 18

Sign-Up: 01/14/05

Posts: 2,976

Acually, he doesnt even know how to make gradiants. I looked at his tutorial, and it just says make a bunch of lines through a square and color them in different shades.

You are a retard!


None

ChocloMan

Reply To Post Reply & Quote

Posted at: 3/28/06 06:50 PM

ChocloMan EVIL LEVEL 14

Sign-Up: 12/17/03

Posts: 4,777

As much as i find this tut good, I have to say there are enough tutorials about play ands stop buttons in the flash help section and in other sites.
D:

Egotist, n. A person of low taste, more interested in himself than in me.
-Ambrose Bierce
"This sig, is fucking cool."

BBS Signature

None

<deleted>

Reply To Post Reply & Quote

Posted at: 9/16/06 06:20 AM

This helped, cheers!


All times are Eastern Standard Time (GMT -5) | Current Time: 10:34 PM

<< 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!