Reputation: 1
I'm creating a simple click and scroll for a future menu for my personal site. I have a box, I called it thing_mc, and I have 3 positions for it. I have a next and prev. button that will control thing_mc position. I'm using TweenLite to animate thing_mc, if that makes a difference.
I get a 1083 error (...else is unexpected) and (...rightparen is unexpected).
Can anyone tell me why and how I can resolve this?
Thanks
import gs.TweenLite;
next_mc.addEventListener(MouseEvent.CLICK, nextListener);
prev_mc.addEventListener(MouseEvent.CLICK, prevListener);
//prev_mc.visible = false;
function nextListener(event:MouseEvent):void
{
if(thing_mc.x == 400);
{
TweenLite.to(thing_mc, .5, {x:50, y:50});
}
else if //// i get error 1083 here (...else is unexpected)
{
TweenLite.to(thing_mc, .5, {x:-100, y:50}); //// i get error 1083 here (...rightparen is unexpected)
}
}
function prevListener(event:MouseEvent):void
{
if(thing_mc.x == -100);
{
TweenLite.to(thing_mc, .5, {x:400, y:50});
}
else if //// i get error 1083 here (...else is unexpected)
{
TweenLite.to(thing_mc, .5, {x:500, y:50}); //// i get error 1083 here (...rightparen is unexpected)
}
}
next_mc.buttonMode = true;
prev_mc.buttonMode = true;
Upvotes: 0
Views: 4858
Reputation: 1
Wats going on is the parser sees if ( cond ) ;
as if ( cond ) /empty statement/ ; //semicolon ends empty statement
(and the else if /.../ of course lacked the parenthesized conditional expr that an if requiress).
I've seen this semicolon related error a lot. It may be because semicolons are optional in some cases in as3.
Upvotes: 0
Reputation: 2112
function nextListener(event:MouseEvent):void
{
if(thing_mc.x == 400);
{
Don't use ;
after the if brackets
;-)
Upvotes: 0
Reputation: 16013
I am not AS expert, but the semicolon after if(thing_mc.x == 400);
and if(thing_mc.x == -100);
seems strange. Should rather read if(thing_mc.x == 400)
and if(thing_mc.x == -100)
I'd say.
Upvotes: 3
Reputation: 111130
else if //// i get error 1083 here (...else is unexpected)
You have a few options here. You can either use a second condition, if you want to use else if
i.e.
else if (someCondition) { ...
or, use just else
else { ...
or use another if
if { ...
It all depends on what you want to achieve.
From what I can see, the second option (plain else
) looks like what you want.
Upvotes: 0