在 flex3/actionscript 中使用超时时出错

发布于 2024-08-23 19:49:48 字数 525 浏览 4 评论 0原文

好吧,这就是我到目前为止所拥有的 - 但它给了我一个错误,说我在某处缺少分号,但我不知道在哪里。基本上我想要它做的是,当单击按钮时,会生成一个随机数,然后隐藏一张图片,显示一张图片 - 然后暂停后,隐藏该图片并显示另一张图片。

<mx:Button x="220" y="10" label="Shuffle the Cards" fontFamily="Times New Roman" fontSize="18" fontStyle="italic" fontWeight="normal"
click="
var shuffleDeck:Function = function shuffle():void {
var randNum:Number = Math.floor(Math.random()*(4))+1;
pic.visible = false;
shuffle.visible = true;
}
setTimeout(shuffle,100);
shuffle.visible = false;
select.visible = true;
"/>

Ok, this is what I have so far - but it gives me an error saying that I am missing a semicolon somewhere, but I cant figure out where. Basically what I want it to do is when the button is clicked a random number is generated, then one pic is hidden, one is shown - then after a pause, that pic is hidden and a different one is shown.

<mx:Button x="220" y="10" label="Shuffle the Cards" fontFamily="Times New Roman" fontSize="18" fontStyle="italic" fontWeight="normal"
click="
var shuffleDeck:Function = function shuffle():void {
var randNum:Number = Math.floor(Math.random()*(4))+1;
pic.visible = false;
shuffle.visible = true;
}
setTimeout(shuffle,100);
shuffle.visible = false;
select.visible = true;
"/>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

逆蝶 2024-08-30 19:49:48

简短回答

    shuffle.visible = true;
}    <--- Semicolon here
setTimeout(shuffle,100);

详细回答

以下实际上只是一个语句(恰好包含一个块):

var shuffleDeck:Function = function shuffle():void {
    var randNum:Number = Math.floor(Math.random()*(4))+1;
    pic.visible = false;
    shuffle.visible = true;
};

...并且像任何其他语句一样,它必须以分号结尾。

块通常不以分号结尾,因此看起来具有欺骗性,但本例中的块只是语句的最后一部分。

short answer

    shuffle.visible = true;
}    <--- Semicolon here
setTimeout(shuffle,100);

long answer

The following is really just a single statement (that happens to contain a block):

var shuffleDeck:Function = function shuffle():void {
    var randNum:Number = Math.floor(Math.random()*(4))+1;
    pic.visible = false;
    shuffle.visible = true;
};

...and like any other statement, it must end with a semicolon.

Blocks don't normally end with a semicolon, so it's deceptive looking, but the block in this case is just the last part of the statement.

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