00:00
00:00
Newgrounds Background Image Theme

vestik 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!

replay button flash cs6 AS3?!?!

2,344 Views | 4 Replies
New Topic Respond to this Topic

replay button flash cs6 AS3?!?! 2012-12-31 05:05:38


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

Response to replay button flash cs6 AS3?!?! 2012-12-31 05:52:42


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

Response to replay button flash cs6 AS3?!?! 2012-12-31 09:57:13


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);
 }

Response to replay button flash cs6 AS3?!?! 2012-12-31 23:30:13


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 noob.

Response to replay button flash cs6 AS3?!?! 2013-01-01 03:41:20


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