2009-10-28 62 views
0

我正在为我的个人网站创建简单的点击和滚动以用于将来的菜单。我有一个盒子,我把它叫做thing_mc,我有三个位置。我有下一个和prev。将控制thing_mc位置的按钮。我正在使用TweenLite为thing_mc设置动画,如果这有所作为。AS3编译器错误1083:使用else语法的问题

我得到一个1083错误(...其他意外)和(... 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; 

回答

0
else if //// i get error 1083 here (...else is unexpected) 

您有几种选择这里。您可以使用第二个条件,如果你想使用else if

else if (someCondition) { ... 

,或者只使用else

else { ... 

或使用其他if

if { ... 

这一切都取决于什么你想实现。

从我所看到的,第二个选项(普通else)看起来像你想要的。

+0

嗨,感谢您的快速回复。 我去了其他{ 工作! – DwayneG 2009-10-28 06:58:17

3

我不是专家,但if(thing_mc.x == 400);if(thing_mc.x == -100);后面的分号似乎很奇怪。应该看看if(thing_mc.x == 400)if(thing_mc.x == -100)我会说。

+0

嗨,感谢您的快速回复。 我删除了那些奇怪的分号,并结合上面的帮助,它工作了! – DwayneG 2009-10-28 06:59:27

+0

因此,请点击左侧数字旁边的大号复选标记,将此答案标记为“已接受”。 – Glenn 2009-10-28 09:16:24

0
function nextListener(event:MouseEvent):void 
{ 
    if(thing_mc.x == 400); 
    { 

后不要使用;的,如果括号 ;-)

0

WATS事情是解析器看到 如果(条件);

as if(cond)/ 空语句 /; //分号结束空语句

(和else if/... /当然缺少括号的条件表达式,如果requiress)。

我见过这个分号相关的错误很多。 这可能是因为在as3中的某些情况下分号是可选的。