English 中文(简体)
ActionScript 出乎意料的卷曲宽带/ Emeromo?
原标题:ActionScript Unexpected Curly Braces/Semicolon?

我编辑了一个ActionScript文件,我遇到了一个问题。

当我写下以下内容时,一切都会好起来的。

if (x=x) {
//blah
}

如果我放这个,它会说出意想不到;一行和一行:

for (x=x) {
//blah
}

当我把这个写在:

while (x=x) {
//blah
}

当然,我只用那些来作为例子来测试它,因为我认为我的代码有问题。在我档案的这一部分中,ActionScript是否只允许IF声明还是什么?我需要对两个不同的字符串采取同样的一系列步骤,但我不想把代码放进去两次。我是否必须做一个函数?

问题回答

在“循环语法”这里

环不使用布尔( true/ false), 它需要一个计数器、 布林检查限制和递增 。

或(或)

for (counter; condition; action){
    statements;
}

我从未使用过动作脚本 但我建议尝试一下

x==x

因为曾经是任务,而不是比较。

如果循环的环环仍然不尝试函数

for(;x==x;){
}

分号告诉它,您只想要使用循环声明中的第二个语句,即条件;因为循环使用三个语句,

for (variable; condition; iterative action)

通过在 x summissionx 之前和之后放置分号,您只能指定条件,这似乎是您试图做的。

使用IF或WHILE 的任何声明都造成了错误,不管里面有什么。

我能够完成我想要的 通过做另一个功能 并发送每一个字符串 尽管那些字符串。

感谢您的帮助, 投票支持你们两个。

您必须写成这样:

if(a==x){
// do that
}


for (x=0; x<maxloops; x++){
// do that
}

while(a==x){
}

= 符号用于定义变量值,而 = = 在比较/检查时必须使用 = = 符号 = 符号 = 用于定义变量值,而 = = = = 在比较/ 检查时必须使用 (即,这是否等于此值) 。 这既适用于 IF 和 WHILE 。

用于 loop 。 可以说您想要执行动作“ 这样做” 10 次。 然后您写

for (x=0; x<10; x++){
    // do that
}

the first part x=0 is the definition of the counting variable and its initial value the second part is the condition (run the loop as long as x is less than 10) the third part is the stepper. (how the counter will raise its value in each loop). x++ is a short way to write x = x +1;





相关问题
Flex: Text Input that accepts number only

Need a code that only accepts numbers. Upon inputting, the code must check if it is number, if not, it must remove the entered key or not enter it at all

How to dynamically generate variables in Action Script 2.0

I have a for loop in action script which I m trying to use to dynamically create variable. Example for( i = 0 ; i &lt 3 ; i++) { var MyVar+i = i; } after this for loop runs, i would like to ...

drag file(s) from destop directly to flash webpage

Could someone please let me know if is possible to drag (multiple) files from desktop directly into a flash webpage. If yes could you please link me to some online resources.

Can XMLSocket send more than once in a frame?

I have a XMLSocket and I call send twice in the same function. The first send works but the second does not? Does XMLSocket have a restriction to only send one message per frame? Do I have to queue ...

How do you stop a setInterval function?

I have a function that I want to run at an interval within a frame. I use the following code to start the function: var intervalID = setInterval(intervalFunction, 3000); Then, in a button s ...

What s a good way of deserializing data into mock objects?

I m writing a mock backend service for my flex application. Because I will likely need to add/edit/modify the mock data over time, I d prefer not to generate the data in code like this: var mockData =...