DPSwebmaster,
> I have given my button an instance name of 'PlayAgain'
and
> placed the AS code on frame 1 of my timeline.
As long as that button (with the instance name PlayAgain)
appears in
frame 1 as well, you should be good.
> PlayAgain.addEventListener(
> MouseEvent.MOUSE_UP,
> function(evt:MouseEvent):void {
> gotoAndPlay(1);
> }
>
There should be a closing parenthesis on that [... this one:
); --
which is basically the other half of the "sandwich" that
begins with
addEventListener( ...]. But other than that, your code looks
fine. Be
advised that you can also use a named function, if you like:
PlayAgain.addEventListener(MouseEvent.MOUSE_UP,
mouseHandler);
function mouseHandler(evt:MouseEvent):void {
gotoAndPlay(1);
}
Do you see how those are effectively the same thing? The
addEventListener() method accepts two parameters: a) an event
to listen for
and b) a function to perform. In the examples I've shown, one
of them
illustrates an anonymous function; the other illustrates a
named function.
In any event, to make sure your code is responding at all,
it may help
to use a trace() function. This is nothing more than a
mechanism to print
text to the Output panel, but it's great for debugging:
PlayAgain.addEventListener(
MouseEvent.MOUSE_UP,
function(evt:MouseEvent):void {
gotoAndPlay(1);
trace("I've been clicked!");
}
);
Try that revision (only one line has changed), and when you
click on the
button, you should see the message "I've been clicked!" in
your Output
panel. If you don't, we'll know that this event listener
isn't getting
assigned properly.
David Stiller
Co-author, ActionScript 3.0 Quick Reference Guide
http://tinyurl.com/2s28a5
"Luck is the residue of good design."