Be a Supporter!

AS: Replay Buttons

  • 10,451 Views
  • 29 Replies
New Topic Respond to this Topic
InglorAntiPostLimit
InglorAntiPostLimit
  • Member since: Nov. 23, 2002
  • Offline.
Forum Stats
Member
Level 03
Blank Slate
AS: Replay Buttons Jul. 3rd, 2005 @ 07:27 AM Reply

AS: Main

This basic tutorial covers on handlers, gotoAndStop, and is for the use of creating a replay button, I will use the most basic stuff I can in order to help practically rather then teach, this is mainly for practical people rather then people who want the actual learning.

I will not cover buttons themselves.

What to do?

Click the "Window" tab, and inside it click "Other Panels" and click "Buttons", a small panel will pop, now go to the last frame of your last scene, click the folders and find a button you would like, I recommand clicking "Circle Button". click the button you would like to use and drag it to the stage for the last frame of the last scene.

Now you have a button on your scene, you need ot make it do stuff ;)
Click the actions panel to open it, if it's not open click "Window"->"Development Panels"->"Actions"

click the button and make sure the Actions panel is now titled "button actions", you can write in it, now let's see what the code is.

first of all we need to tell the button WHEN to trigger, we can make it trigger when the mouse is over it, when it is released on it, when it is pressed on it, when a certein key is down, and many more, this is done by the "on" button handler

on(release) triggers when the mouse is released over the button
on(press) triggers when the mouse is pressed over the button

these are the main two we will use since they are the most common.

after a handler in flash we always use '{' brackets to specify the start and end location of the code that handler triggers, so generally

on(release){
<Code Here>
}

is the syntax we will use.

let's now look into the current frame manipulation flash provides us with, there are several
remarks are in //

stop(); //this action causes the movie to stop
play(); //this action causes the movie to play
nextFrame(); //this action cuases the movie to go to the next frame as stop
prevFrame();//same as nextFrame, only it goes to the previous frame
nextScene();//goes to the next scene and stops
prevScene();//goes to the prev scene and stops
gotoAndStop(<frameNumber>); //goes to a certein frame number (or label) and stops
gotoAndPlay(<frameNumber>); //goes to a certein frame number (or label), and plays
gotoAndStop(<scene>,<frameNumber>);//goes to a certein frame in a certein scene and //stops
gotoAndPlay(<scene>,<frameNumber>);//goes to a certein frame in a certein scene and //plays

the most powerful method is the one we will used, gotoAndPlay(<scene>,<frameNumber);
by placing this action, once triggered (when the on statement occurs) the flash movie will go to the given frame in the given scene

I will presume you want to go to the second frame in your first scene for replay

our actions were

on(release){

}

and we will now add the gotoAndPlay part

on(release){
gotoAndPlay("Scene 1",2);
}

the frame number can be a number between 1 and the total frames in the scene, the scene name must be accurate, it is case sensative, if you don't use scenes, drop it and use gotoAndPlay(<frameNumber); instead.

to find out the accurate scene name click "Window"->"Design Panels"->"Scene". use the scene name (case sensative) exactly as shown there.

for those of you who use movieclips, don't pkace this code anywhere in a movieclip for path reasons, the button must be on the base timeline

hope this helps.

ask any questions.

Inglor

p.s.
sorry for having to use the APS account again.

T-H
T-H
  • Member since: Jan. 7, 2004
  • Offline.
Forum Stats
Member
Level 40
Blank Slate
Response to AS: Replay Buttons Jul. 3rd, 2005 @ 07:49 AM Reply

Lol this really for the complete noobs

Inglor
Inglor
  • Member since: Jan. 26, 2003
  • Offline.
Forum Stats
Member
Level 17
Blank Slate
Response to AS: Replay Buttons Jul. 3rd, 2005 @ 07:53 AM Reply

or just people who are good with art but can't script stuff ;)

BleeBlap
BleeBlap
  • Member since: Mar. 8, 2005
  • Offline.
Forum Stats
Member
Level 24
Blank Slate
Response to AS: Replay Buttons Jul. 15th, 2005 @ 06:11 AM Reply

Or people who are like me and stay up too late at night programming and start to lose their mind. I was trying to link to another scene with a basic button. You know, the same question we answer several times a day:

on (release) {
gotoAndPlay("Credits", 1);
}

AND IT WASN'T WORKING! I looked it up in the actionscript dictionary. I looked at this thread. I was going crazy labeling frames and trying gotoAndStop vs. gotoAndPlay. I was doing EVERYTHING and it wouldn't work, that is until I realized I kept doing test scene which aparently doesn't load the other scenes and therefore won't link to them even if you tell it to. Anyway, thats a little tip to anybody who might have the correct syntax and still be having problems. Always test your whole movie! I can't beleive I wasted 30 minutes of my life on that.

Inglor
Inglor
  • Member since: Jan. 26, 2003
  • Offline.
Forum Stats
Member
Level 17
Blank Slate
Response to AS: Replay Buttons Aug. 28th, 2005 @ 05:30 PM Reply

http://www.newground../topic.php?id=335033
AS: Animated Buttons by Inglor

Inglor
Inglor
  • Member since: Jan. 26, 2003
  • Offline.
Forum Stats
Member
Level 17
Blank Slate
Response to AS: Replay Buttons Aug. 28th, 2005 @ 05:34 PM Reply

oops, I was sure I am in AS: Main lol, used this as a reference in the new animated buttons one

von-Brunk
von-Brunk
  • Member since: Mar. 18, 2003
  • Offline.
Forum Stats
Member
Level 41
Artist
Response to AS: Replay Buttons Oct. 14th, 2005 @ 01:46 PM Reply

I know how to make replay buttons, but I'm making a parody of a free iPod banner (you know, like the ones you see all over this site), and I have the basic coding and everythinhg ready... I have the objects, the custom cursor and everything done, but there's one small problem: When you kill the target object, it cuts to a movie clip of the object dying. When it finishes dying, it stops (using the stop action script), and a replay button appears within the death movie clip. When you click it to replay, it just replays the movie clip.

How can I make the replay button refresh the actual flash game itself instead of simply replaying the movie clip? Or, is there some way to make a replay button appear in the middle of the flash game when the death movie clip is done playing?


Hey kids!

BBS Signature
liam
liam
  • Member since: Dec. 11, 2004
  • Offline.
Forum Stats
Member
Level 22
Blank Slate
Response to AS: Replay Buttons Oct. 14th, 2005 @ 01:51 PM Reply

At 10/14/05 01:46 PM, von_Brunk wrote: stuff

Put _root at the front of the gotoAndPlay command on the button =P


Sup, bitches :)

BBS Signature
von-Brunk
von-Brunk
  • Member since: Mar. 18, 2003
  • Offline.
Forum Stats
Member
Level 41
Artist
Response to AS: Replay Buttons Oct. 14th, 2005 @ 02:12 PM Reply

At 10/14/05 01:51 PM, -liam- wrote:
At 10/14/05 01:46 PM, von_Brunk wrote: stuff
Put _root at the front of the gotoAndPlay command on the button =P

Where? Here's what mine looks like:

on(release){
gotoAndPlay("Scene 1", 1);
}


Hey kids!

BBS Signature
liam
liam
  • Member since: Dec. 11, 2004
  • Offline.
Forum Stats
Member
Level 22
Blank Slate
Response to AS: Replay Buttons Oct. 14th, 2005 @ 02:13 PM Reply

Try changing it to this:

on(release){
_root.gotoAndPlay(1);
}

It will automatically goto Scene 1, Frame 1 if you don't specify a scene.


Sup, bitches :)

BBS Signature
von-Brunk
von-Brunk
  • Member since: Mar. 18, 2003
  • Offline.
Forum Stats
Member
Level 41
Artist
Response to AS: Replay Buttons Oct. 14th, 2005 @ 02:27 PM Reply

Ok, it sort of worked. I got the movie to replay from the beginning, but the movie clip that continuously loops around at the start of the movie is the last frame of the death animation (including the replay button), instead of the very start of the non-dead target.


Hey kids!

BBS Signature
Zielak
Zielak
  • Member since: Sep. 21, 2005
  • Offline.
Forum Stats
Member
Level 17
Blank Slate
Response to AS: Replay Buttons Oct. 14th, 2005 @ 02:37 PM Reply

this tutorial is for noobz... ,but there are some noobz in NG BBS who will need this ;P
======================================

At 8/28/05 05:34 PM, Inglor wrote: oops, I was sure I am in AS: Main lol, used this as a reference in the new animated buttons one

lolzs ;D

Joevan
Joevan
  • Member since: Aug. 5, 2005
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to AS: Replay Buttons Nov. 19th, 2005 @ 08:47 PM Reply

At 7/3/05 07:53 AM, Inglor wrote: or just people who are good with art but can't script stuff ;)

Like me, thousands of thanks for help! Gonna submit my movie tomorrow thanks to this topic.

Johnny
Johnny
  • Member since: Apr. 17, 2004
  • Offline.
Forum Stats
Member
Level 24
Blank Slate
Response to AS: Replay Buttons Nov. 19th, 2005 @ 09:00 PM Reply

At 7/3/05 07:49 AM, T-H wrote: Lol this really for the complete noobs

What's a gotoAndPlay()? Can I use that to make platformers?

U guyz R 1337! R1t3 a c0d3 4 m3!

Nah Ing, I think it's a good thing. I didn't see any links in AS: Main that really went into the basic of basics. Good stuff.


Perpetually looking for time to return to the arts.

BBS Signature
RWS
RWS
  • Member since: Mar. 11, 2005
  • Offline.
Forum Stats
Member
Level 23
Blank Slate
Response to AS: Replay Buttons Nov. 19th, 2005 @ 10:15 PM Reply

At 7/15/05 06:11 AM, BleeBlap wrote: I can't beleive I wasted 30 minutes of my life on that.

Oh BleeBlap, those 30 minutes weren't wasted, you learnt a very valuable lesson, NOW NEVER DISSAPOINT ME AGAIN, i dont want any AS errors from you, you hear!

XenNetwork
XenNetwork
  • Member since: Oct. 2, 2004
  • Offline.
Forum Stats
Member
Level 04
Blank Slate
Response to AS: Replay Buttons May. 23rd, 2006 @ 05:43 PM Reply

um how do u do it if its a botten im a noob

PowerRangerYELLOW
PowerRangerYELLOW
  • Member since: Jan. 1, 2004
  • Offline.
Forum Stats
Member
Level 16
Blank Slate
Response to AS: Replay Buttons May. 24th, 2006 @ 01:46 PM Reply

Bump

all this action script will really come in handy when ever i get stuck.

angelo-ryan
angelo-ryan
  • Member since: May. 6, 2006
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to AS: Replay Buttons Jul. 30th, 2006 @ 05:27 AM Reply

This doesn't work for Flash 8...I don't have a Buttons option in Other Libraries.

edit-undo
edit-undo
  • Member since: Jan. 17, 2006
  • Offline.
Forum Stats
Member
Level 19
Blank Slate
Response to AS: Replay Buttons Jul. 30th, 2006 @ 06:25 AM Reply

At 7/30/06 05:27 AM, angelo_ryan wrote: This doesn't work for Flash 8...I don't have a Buttons option in Other Libraries.

So make your own button! All you've got to is draw something, convert it to a symbol, and select the 'button' option. Voila!


...

BBS Signature
Areek
Areek
  • Member since: Aug. 7, 2006
  • Offline.
Forum Stats
Member
Level 06
Blank Slate
Response to AS: Replay Buttons Aug. 7th, 2006 @ 08:07 PM Reply

i have tryed every code here but it just come error!!
i want to have a replay button can someone help me im a noob :P


BBS Signature
DCorp
DCorp
  • Member since: Nov. 25, 2006
  • Offline.
Forum Stats
Member
Level 16
Blank Slate
Response to AS: Replay Buttons Jan. 14th, 2007 @ 09:16 PM Reply

well it dosen't take a genuis to make a replay button
i figuired that out when i first started flash


|| DcOrP|| You can't spell harDCORe Porn without DCORP.
Bring Amber Lamps

BBS Signature
Grim-The-Unholy
Grim-The-Unholy
  • Member since: Feb. 24, 2005
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to AS: Replay Buttons Mar. 31st, 2007 @ 03:12 PM Reply

yeah, it's easy, but my first mistake was stupid...
on(press){
gotoAndPaly(3);
}
I couldn't figure out what i'd done wrong, it took me 3 weeks to realise...

DragonFruit-Rock
DragonFruit-Rock
  • Member since: Dec. 31, 2005
  • Offline.
Forum Stats
Member
Level 13
Blank Slate
Response to AS: Replay Buttons Jul. 19th, 2007 @ 11:57 AM Reply

well you did this tutorial really well considering how little there is to do!


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
st91
st91
  • Member since: Aug. 20, 2008
  • Offline.
Forum Stats
Member
Level 06
Blank Slate
Response to AS: Replay Buttons Aug. 24th, 2008 @ 04:09 AM Reply

At 7/3/05 07:53 AM, Inglor wrote: or just people who are good with art but can't script stuff ;)

true that


Your parents told me to tell you that you are a douche

Dayu
Dayu
  • Member since: Jun. 21, 2009
  • Offline.
Forum Stats
Member
Level 01
Blank Slate
Response to AS: Replay Buttons Aug. 24th, 2009 @ 04:27 PM Reply

thanks for this. I'm a total noob in AS...
Was just doing a replay button, but without success. I try this tutorial tomorrow.

I'm glad I found preloaders at Newgrounds here, otherwise I'd go totally nuts.

And yeah, sorry for beeing a noob. Reading commens like "omg, this is just for noobz!" http://www.newgrounds.com/bbs/post/reply /299751#

MarioFlashMovies
MarioFlashMovies
  • Member since: Nov. 26, 2007
  • Offline.
Forum Stats
Member
Level 14
Blank Slate
Response to AS: Replay Buttons Aug. 24th, 2009 @ 04:46 PM Reply

Thanks, it helped me when I was a n00b.
(Pressed replay)
Thanks, it helped me when I was a n00b.


Super Sprite Fight Collab | The Kirby Collab | YouTube | Yup, the image is the header of my company.

BBS Signature
IaReFrEaKeeee
IaReFrEaKeeee
  • Member since: Mar. 9, 2006
  • Offline.
Forum Stats
Member
Level 14
Blank Slate
Response to AS: Replay Buttons Nov. 12th, 2009 @ 01:46 PM Reply

I've been trying all fucking week to get this god damned Replay button to work, but it wont. I want it to go to Scene 1, frame 1, and it wont.

And i can't delete the extra scene I have at the end. ugh.

forgive me, I'm frutrated.

replay.addEventListener(MouseEvent.CLICK , onClick);

function onClick(event:MouseEvent):void
{
gotoAndPlay("Scene 1",1);
}

thats what I have so far, obviously not working. I just want it to go back to scene 1/frame1!! what sso hard about that!!! D'X

Yambanshee
Yambanshee
  • Member since: Oct. 5, 2008
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to AS: Replay Buttons Nov. 12th, 2009 @ 02:10 PM Reply

At 11/12/09 01:46 PM, IaReFrEaKeeee wrote: rant

are you using AS2 or AS3. that code is AS3 and this tutorial is AS2


AS2||AS3||Motox
Thanks to hdxmike for the sig :]

BBS Signature
IaReFrEaKeeee
IaReFrEaKeeee
  • Member since: Mar. 9, 2006
  • Offline.
Forum Stats
Member
Level 14
Blank Slate
Response to AS: Replay Buttons Nov. 12th, 2009 @ 03:09 PM Reply

yes, I'm using as3

oops. can u help anyways?
Chinnaru
Chinnaru
  • Member since: Feb. 6, 2009
  • Offline.
Forum Stats
Member
Level 04
Blank Slate
Response to AS: Replay Buttons Nov. 20th, 2009 @ 03:08 AM Reply

At 7/30/06 05:27 AM, angelo-ryan wrote: This doesn't work for Flash 8...I don't have a Buttons option in Other Libraries.

just go to ''window'' then ''other libruaries'' then buttons should b in there