AS3 编译器错误 1083:else 语法有问题

发布于 2024-08-09 08:01:13 字数 1116 浏览 3 评论 0原文

我正在为我的个人网站的未来菜单创建一个简单的点击和滚动。我有一个盒子,我称之为 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

感悟人生的甜 2024-08-16 08:01:13

我不是 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); 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.

三月梨花 2024-08-16 08:01:13
else if //// i get error 1083 here (...else is unexpected)

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

else if (someCondition) { ...

,或者仅使用 else

else { ...

或使用另一个 if

if { ...

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

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

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.

骄兵必败 2024-08-16 08:01:13
function nextListener(event:MouseEvent):void
{
    if(thing_mc.x == 400);
    {

不要在 if 括号后使用 ;
;-)

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

Don't use ; after the if brackets
;-)

蓦然回首 2024-08-16 08:01:13

解析器看到正在发生的事情
如果(条件);

作为
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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文