ActionScript三元运算符

时间:2010-07-07 13:01:55

标签: actionscript-3 ternary-operator

在动作脚本中

str是string var

str=(some condition)?" store true":"store false";

当我警告str没有收到任何消息时......为什么没有得到

代码:

[Bindable]
public var errVarMsg:String ;

errVarMsg="";
errVarMsg=(minfee<=maxfee)?"":"fee min > max\n";
Alert.show(errVarMsg);

1 个答案:

答案 0 :(得分:3)

如果minfee小于或等于maxfee,您将收到空警报,可能会被视为无消息。将其更改为

minfee = 5;
maxfee = 10;
errVarMsg = (minfee <= maxfee) ? "min <= max" : "min > max";
Alert.show(errVarMsg);

minfee = 15;
maxfee = 10;
errVarMsg = (minfee <= maxfee) ? "min <= max" : "min > max";
Alert.show(errVarMsg);