Be a Supporter!

As: Play And Stop Buttons

  • 4,605 Views
  • 17 Replies
New Topic Respond to this Topic
Inglor
Inglor
  • Member since: Jan. 26, 2003
  • Offline.
Forum Stats
Member
Level 17
Blank Slate
As: Play And Stop Buttons 2005-07-19 10:07:44 Reply

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

liam
liam
  • Member since: Dec. 11, 2004
  • Offline.
Forum Stats
Member
Level 22
Blank Slate
Response to As: Play And Stop Buttons 2005-07-19 10:18:51 Reply

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
gorman2001
gorman2001
  • Member since: Aug. 18, 2002
  • Offline.
Forum Stats
Member
Level 14
Blank Slate
Response to As: Play And Stop Buttons 2005-07-19 10:20:40 Reply

god!

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


website :: hugostonge.com
my job :: we+are

Inglor
Inglor
  • Member since: Jan. 26, 2003
  • Offline.
Forum Stats
Member
Level 17
Blank Slate
Response to As: Play And Stop Buttons 2005-07-19 10:21:02 Reply

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

Inglor
Inglor
  • Member since: Jan. 26, 2003
  • Offline.
Forum Stats
Member
Level 17
Blank Slate
Response to As: Play And Stop Buttons 2005-07-19 10:22:05 Reply

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

CaptinChu
CaptinChu
  • Member since: Sep. 11, 2005
  • Offline.
Forum Stats
Member
Level 15
Blank Slate
Response to As: Play And Stop Buttons 2005-11-18 06:42:26 Reply

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?

Sluf
Sluf
  • Member since: Oct. 18, 2003
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to As: Play And Stop Buttons 2005-11-18 06:44:52 Reply

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

Khao
Khao
  • Member since: Sep. 20, 2003
  • Offline.
Forum Stats
Member
Level 20
Blank Slate
Response to As: Play And Stop Buttons 2005-11-18 08:05:14 Reply

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

GuyWithHisComp
GuyWithHisComp
  • Member since: Nov. 10, 2005
  • Offline.
Forum Stats
Member
Level 28
Blank Slate
Response to As: Play And Stop Buttons 2005-11-18 11:20:05 Reply

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
GumSlough
GumSlough
  • Member since: Mar. 23, 2006
  • Offline.
Forum Stats
Member
Level 04
Blank Slate
Response to As: Play And Stop Buttons 2006-03-28 08:25:15 Reply

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

Inglor
Inglor
  • Member since: Jan. 26, 2003
  • Offline.
Forum Stats
Member
Level 17
Blank Slate
Response to As: Play And Stop Buttons 2006-03-28 10:13:26 Reply

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

GustTheASGuy
GustTheASGuy
  • Member since: Nov. 2, 2005
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to As: Play And Stop Buttons 2006-03-28 10:17:16 Reply

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


BBS Signature
DragonFruit-Rock
DragonFruit-Rock
  • Member since: Dec. 31, 2005
  • Offline.
Forum Stats
Member
Level 13
Blank Slate
Response to As: Play And Stop Buttons 2006-03-28 10:58:12 Reply

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
Inglor
Inglor
  • Member since: Jan. 26, 2003
  • Offline.
Forum Stats
Member
Level 17
Blank Slate
Response to As: Play And Stop Buttons 2006-03-28 11:14:06 Reply

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

Toast
Toast
  • Member since: Apr. 2, 2005
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
Response to As: Play And Stop Buttons 2006-03-28 11:28:34 Reply

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
Pyromaniac
Pyromaniac
  • Member since: Jan. 14, 2005
  • Offline.
Forum Stats
Member
Level 18
Blank Slate
Response to As: Play And Stop Buttons 2006-03-28 18:45:48 Reply

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!

ChocloMan
ChocloMan
  • Member since: Dec. 17, 2003
  • Offline.
Forum Stats
Member
Level 14
Blank Slate
Response to As: Play And Stop Buttons 2006-03-28 18:50:28 Reply

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
<deleted>
Response to As: Play And Stop Buttons 2006-09-16 06:20:44 Reply

This helped, cheers!