向flash高手请教

来源:百度知道 编辑:UC知道 时间:2024/06/24 09:31:09
请问
if(_root.aa._currentframe==4||1)
{}


if(_root.aa._currentframe==4)
{}
else if(_root.aa._currentframe==1)
{}

为什么两种情况不一样?

就算不是flash高手,这个问题也是非常明显的,这是运算符优先级的问题。

if(_root.aa._currentframe==4||1) 一句是先进行(4||1)的或操作,(4||1)的结果是真,也就是1,然后进行_root.aa._currentframe==1的判断

而if(_root.aa._currentframe==4)
{}
else if(_root.aa._currentframe==1)
{}
这一段是先进行的_root.aa._currentframe==4的判断,如果_root.aa._currentframe不等于4则进行_root.aa._currentframe==1的判断

看出来2个不一样了吧,如果你想让第1个和第2个功能一样,就要写成

if((_root.aa._currentframe==4)||(_root.aa._currentframe==1))
{}

回答完毕