Skip to main content
Known Participant
May 13, 2006
Question

PLEASE CAN YOU TELL ME WHAT THIS ERROR MEANS?

  • May 13, 2006
  • 3 replies
  • 356 views
The script attached to my button reads:-

//This script takes the user to Scene 1 when opendoor is released
on(Release) = function (){
gotoAndStop("Scene 1", 1);
};

The errors in the Output Panel are:-

**Error** Scene=Scene 2, layer=door, frame=1:Line 2: '{' expected
on(Release) = function () {

**Error** Scene=Scene 2, layer=door, frame=1:Line 4: Statement must appear within on handler
};

I will be eternally grateful to anyone who can sort me out!!

This topic has been closed for replies.

3 replies

May 13, 2006
Also note that using scenes with gotoAndPlay/Stop is buggy. It has been advised by many to use the MovieClip method, along with frame labels. In your case, all you would need is:

_root.gotoAndStop(1);
Inspiring
May 13, 2006
Don't confuse the on(xxx) handlers with the onXXX events:
on(release){
// actions
}

vs.

onRelease = function(){
// actions
}

The on(xxx) handlers have to be bound to an object directly (placed in the code attached to an instance), the onXXX events have to be placed in the timeline, and normally have the instance they are bound to specified in dot syntax, like
button1.onRelease = ...

greets,
blemmo
Inspiring
May 13, 2006
SLMHILL wrote:
> The script attached to my button reads:-
>
> //This script takes the user to Scene 1 when opendoor is released
> on(Release) = function (){
> gotoAndStop("Scene 1", 1);
> };
>
> The errors in the Output Panel are:-
>
> **Error** Scene=Scene 2, layer=door, frame=1:Line 2: '{' expected
> on(Release) = function () {
>
> **Error** Scene=Scene 2, layer=door, frame=1:Line 4: Statement must appear
> within on handler
> };
>
> I will be eternally grateful to anyone who can sort me out!!
>
>
>

SLMHILL,

You're mixing two ways of writing event handlers. If you want to attach
the script to your button directly, use this code:

on(Release) {
gotoAndStop("Scene 1", 1)
}

Or, if you want to place all of the scripting in one place, on a frame
on the main timeline, you would use the code below.

opendoor.onRelease = function (){
gotoAndStop("Scene 1", 1);
};

To do this, make sure your button on the stage has an instance name of
"opendoor" -- instance name is in the Properties panel.

Then make a new layer called "actions" and make sure to click on it in
the timeline, then open the Actions panel and write the code.
SLMHILLAuthor
Known Participant
May 13, 2006
Thanks, I'll try again