Be a Supporter!

Actionscript 3 help!!!

  • 478 Views
  • 6 Replies
New Topic Respond to this Topic
sweetcommando
sweetcommando
  • Member since: Jul. 29, 2011
  • Offline.
Forum Stats
Member
Level 24
Animator
Actionscript 3 help!!! 2012-10-07 18:54:49 Reply

so I'm pretty newbie at actionscript. I actually have no experience in it. Anyway, does anyboady know how to make a replay button? I already saw some tutorials online but they don't say how to make it go to the first scene and frame. Please help.

IndigenousDigitalist
IndigenousDigitalist
  • Member since: Sep. 24, 2010
  • Offline.
Forum Stats
Member
Level 13
Game Developer
Response to Actionscript 3 help!!! 2012-10-07 20:33:20 Reply

At 10/7/12 06:54 PM, sweetcommando wrote: so I'm pretty newbie at actionscript. I actually have no experience in it. Anyway, does anyboady know how to make a replay button? I already saw some tutorials online but they don't say how to make it go to the first scene and frame. Please help.

Put a button on the stage and give it an instance name of 'replayButton', then put this in the actions panel:

import flash.events.MouseEvent; //Gets the event of clicking
stop(); //Stops the frame
replayButton.addEventListener(MouseEvent.CLICK, replay); //When you click on the replayButton, do the replay function
function replay(e:MouseEvent){//Declare replay function with a tie to a MouseEvent
gotoAndPlay(1,"Scene 1");//send you back to Scene 1 Frame 1
}//close the function

In the future, I wouldn't recommend using scenes in the first place. They're just annoying.


BBS Signature
egg82
egg82
  • Member since: Jun. 24, 2006
  • Offline.
Forum Stats
Supporter
Level 05
Game Developer
Response to Actionscript 3 help!!! 2012-10-07 21:46:29 Reply

At 10/7/12 06:54 PM, sweetcommando wrote: so I'm pretty newbie at actionscript. I actually have no experience in it. Anyway, does anyboady know how to make a replay button? I already saw some tutorials online but they don't say how to make it go to the first scene and frame. Please help.

grab yourself FlashDevelop (it's free) and learn yourself some AS3. There's a lot of good tutorials out there. I made one myself, but it assumes you already know some AS and are looking to switch from AS2 to AS3.

DO NOT USE AS2!!!
^ Seriously. If you're using AS2 right now, then stop what you're doing and learn AS3.

as to your problem:

make a button, name it SWC_button, and export it as an SWC along with all of your other GUI elements. Then use this in your Main.as in FD:

private var _button:SWC_button = new SWC_button();

//Constructor stuff here

public function init(e:Event = null):void{
	removeEventListener(Event.ADDED_TO_STAGE, init);
	
	_button.addEventListener(MouseEvent.CLICK, replay);
	addChild(_button);
}

private function replay(e:MouseEvent):void{
	_button.removeEventListener(MouseEvent.CLICK, replay);
	removechild(_button);
	//"replay your animation" code here
}

Programming stuffs (tutorials and extras)
PM me (instead of MintPaw) if you're confuzzled.
thank Skaren for the sig :P

BBS Signature
Tree-SkyLark-BCE
Tree-SkyLark-BCE
  • Member since: Aug. 6, 2005
  • Offline.
Forum Stats
Member
Level 35
Programmer
Response to Actionscript 3 help!!! 2012-10-07 22:12:18 Reply

At 10/7/12 09:46 PM, egg82 wrote: grab yourself FlashDevelop (it's free) and learn yourself some AS3. There's a lot of good tutorials out there. I made one myself, but it assumes you already know some AS and are looking to switch from AS2 to AS3.

DO NOT USE AS2!!!
^ Seriously. If you're using AS2 right now, then stop what you're doing and learn AS3.

Don't you think your solution is a bit overkill? Unless Sweetcommando is making something more interactive than an animation, IndigenousDigitalist's answer seems perfectly suitable for the situation. Plus, FlashDevelop supports Flash IDE projects, so exporting a SWC is unnecessary.


BBS Signature
sweetcommando
sweetcommando
  • Member since: Jul. 29, 2011
  • Offline.
Forum Stats
Member
Level 24
Animator
Response to Actionscript 3 help!!! 2012-10-07 22:24:23 Reply

im not going to learn actionscript because im not focusing on making games. all i need is some simple references on simple movie interactions. but thanks anyway, i figured it out.

egg82
egg82
  • Member since: Jun. 24, 2006
  • Offline.
Forum Stats
Supporter
Level 05
Game Developer
Response to Actionscript 3 help!!! 2012-10-07 23:41:02 Reply

At 10/7/12 10:12 PM, Tree-SkyLark-BCE wrote: Don't you think your solution is a bit overkill? Unless Sweetcommando is making something more interactive than an animation, IndigenousDigitalist's answer seems perfectly suitable for the situation. Plus, FlashDevelop supports Flash IDE projects, so exporting a SWC is unnecessary.

true, I just assumed there was going to be more than a "replay" button on the stage. If the button's all you have, then the first solution is better.

At 10/7/12 10:24 PM, sweetcommando wrote: im not going to learn actionscript because im not focusing on making games. all i need is some simple references on simple movie interactions. but thanks anyway, i figured it out.

WHOOPS, you're an animator! Nevermind what I said, then :P


Programming stuffs (tutorials and extras)
PM me (instead of MintPaw) if you're confuzzled.
thank Skaren for the sig :P

BBS Signature
sweetcommando
sweetcommando
  • Member since: Jul. 29, 2011
  • Offline.
Forum Stats
Member
Level 24
Animator
Response to Actionscript 3 help!!! 2012-10-08 07:38:55 Reply

WHOOPS, you're an animator! Nevermind what I said, then :P

thanks for the help anyway