Be a Supporter!

replay button flash cs6 AS3?!?!

  • 1,170 Views
  • 4 Replies
New Topic Respond to this Topic
Imasock
Imasock
  • Member since: Dec. 31, 2012
  • Offline.
Forum Stats
Member
Level 04
Gamer
replay button flash cs6 AS3?!?! Dec. 31st, 2012 @ 05:05 AM Reply

I am nearly at the peak of finishing an animation.. i just have no clue how to make a replay button.
I've tried

stop();
replay.addEventListener(MouseEvent.CLICK, Shoot_1);

function Shoot_1(event:MouseEvent):void
{
gotoAndPlay(1);
}

but get the error message "Scene 1, Layer 'Action Script', Frame 505, Line 2 1120:Access of undefined property replay.


Sincerly,

Sockboy

BBS Signature
egg82
egg82
  • Member since: Jun. 24, 2006
  • Offline.
Forum Stats
Member
Level 05
Game Developer
Response to replay button flash cs6 AS3?!?! Dec. 31st, 2012 @ 05:52 AM Reply

replay is null or undefined when the addEventListener function is called. Try tracing your values throughout the function.

by the way: Every time you code on the timeline, god smites a kitten. If you want to continue coding I (and many others) highly recommend the free program FlashDevelop.


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

BBS Signature
teejay-number13
teejay-number13
  • Member since: Oct. 7, 2004
  • Offline.
Forum Stats
Supporter
Level 25
Programmer
Response to replay button flash cs6 AS3?!?! Dec. 31st, 2012 @ 09:57 AM Reply

At 12/31/12 05:05 AM, Imasock wrote: I am nearly at the peak of finishing an animation.. i just have no clue how to make a replay button.
I've tried

stop();
replay.addEventListener(MouseEvent.CLICK, Shoot_1);

function Shoot_1(event:MouseEvent):void
{
gotoAndPlay(1);
}

but get the error message "Scene 1, Layer 'Action Script', Frame 505, Line 2 1120:Access of undefined property replay.

The error message is basically saying that flash doesn't know what "replay" is? So what is replay? It should be the name of your button. Make sure the button is on the stage when the eventlistener is created and that it's instance name is 'replay'.

If you did all that and you're still getting the error message, it may be that when you jump back to frame one, the button is now gone but the eventlistener is still looking for it. Make sure to remove all you event listeners when they are no longer needed.

like this:

function Shoot_1(event:MouseEvent):void
{
replay.removeEventListener(MouseEvent.CLICK, Shoot_1);
 gotoAndPlay(1);
 }
CzeryWassierSwizier
CzeryWassierSwizier
  • Member since: May. 15, 2010
  • Offline.
Forum Stats
Member
Level 12
Blank Slate
Response to replay button flash cs6 AS3?!?! Dec. 31st, 2012 @ 11:30 PM Reply

At 12/31/12 05:52 AM, egg82 wrote: by the way: Every time you code on the timeline, god smites a kitten. If you want to continue coding I (and many others) highly recommend the free program FlashDevelop.

I really don't think a simple replay button calls the need for an IDE.
Coding on the timeline isn't pretty, but it works for light coding in general.


I'm a nub.

egg82
egg82
  • Member since: Jun. 24, 2006
  • Offline.
Forum Stats
Member
Level 05
Game Developer
Response to replay button flash cs6 AS3?!?! Jan. 1st, 2013 @ 03:41 AM Reply

At 12/31/12 11:30 PM, CzeryWassierSwizier wrote: I really don't think a simple replay button calls the need for an IDE.
Coding on the timeline isn't pretty, but it works for light coding in general.

I did say "continue coding" - and if you wanted to program a simple button or two, AS1/2 does actually have a use, there. I don't think using class structure is wise when making, what, one or two buttons?


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

BBS Signature