AS3 编译器错误 1083:else 语法有问题
我正在为我的个人网站的未来菜单创建一个简单的点击和滚动。我有一个盒子,我称之为 thing_mc,我有 3 个位置。我有下一个和上一个。控制 thing_mc 位置的按钮。我正在使用 TweenLite 来制作 thing_mc 动画,如果这有什么不同的话。
我收到 1083 错误(...else 是意外的)和(...rightparen 是意外的)。
谁能告诉我为什么以及如何解决这个问题?
谢谢
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;
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;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我不是 AS 专家,但是
if(thing_mc.x == 400);
和if(thing_mc.x == -100);
后面的分号看起来很奇怪。我想说的是,应该阅读if(thing_mc.x == 400)
和if(thing_mc.x == -100)
。I am not AS expert, but the semicolon after
if(thing_mc.x == 400);
andif(thing_mc.x == -100);
seems strange. Should rather readif(thing_mc.x == 400)
andif(thing_mc.x == -100)
I'd say.您在这里有几个选择。您可以使用第二个条件,如果您想使用
else if
即,或者仅使用
else
或使用另一个
if
这一切都取决于你想要实现什么。
据我所知,第二个选项(普通的
else
)看起来像你想要的。You have a few options here. You can either use a second condition, if you want to use
else if
i.e.or, use just
else
or use another
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.不要在 if 括号后使用
;
;-)
Don't use
;
after the if brackets;-)
解析器看到正在发生的事情
如果(条件);
作为
if ( cond ) /空语句/ ; // 分号结束空语句
(else if /.../ 当然缺少 if 所需的带括号的条件表达式)。
我经常看到这个与分号相关的错误。
这可能是因为在 as3 中分号在某些情况下是可选的。
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.