00:00
00:00
Newgrounds Background Image Theme

Chan99 just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

As: Play And Stop Buttons

6,101 Views | 15 Replies
New Topic Respond to this Topic

As: Play And Stop Buttons 2005-07-19 10:07:44


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

Response to As: Play And Stop Buttons 2005-07-19 10:18:51


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

Sup, bitches :)

BBS Signature

Response to As: Play And Stop Buttons 2005-07-19 10:20:40


god!

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


website :: hugostonge.com

my job :: we+are

Response to As: Play And Stop Buttons 2005-07-19 10:21:02


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 :)

Response to As: Play And Stop Buttons 2005-07-19 10:22:05


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

Response to As: Play And Stop Buttons 2005-11-18 06:42:26


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?

Response to As: Play And Stop Buttons 2005-11-18 06:44:52


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

Response to As: Play And Stop Buttons 2005-11-18 11:20:05


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

Response to As: Play And Stop Buttons 2006-03-28 08:25:15


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?)

Response to As: Play And Stop Buttons 2006-03-28 10:13:26


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

Response to As: Play And Stop Buttons 2006-03-28 10:17:16


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


BBS Signature

Response to As: Play And Stop Buttons 2006-03-28 10:58:12


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

Response to As: Play And Stop Buttons 2006-03-28 11:14:06


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 :)

Response to As: Play And Stop Buttons 2006-03-28 11:28:34


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


BBS Signature

Response to As: Play And Stop Buttons 2006-03-28 18:50:28


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

Response to As: Play And Stop Buttons 2006-09-16 06:20:44


This helped, cheers!