flex as3 执行复杂的条件语句
来源:互联网 发布:java获取字符串编码 编辑:程序博客网 时间:2024/05/01 01:39
问题
我要在多个条件中做出决定
解决办法
可以使用逻辑运算符AND (&&), OR (||), 和 NOT (!) 来创建符合条件语句。
讨论
ActionScript中的很多语句都能包含条件表达式。包括 if, while, 和 for 语句,如果测试两个条件都成立可以使用逻辑运算符 AND , &&, (更多细节请看第14章):
// 测试今天是否是3月17号
var current:Date = new Date( );
if (current.getDate( ) == 17 && current.getMonth( ) == 3) {
trace ("Happy Birthday, Bruce!");
}
加入些括号让结构更加清晰:
// Check if today is April 17th.
if ((current.getDate( ) == 17) && (current.getMonth( ) == 3)) {
trace ("Happy Birthday, Bruce!");
}
这里使用了逻辑运算符OR , ||, 来测试是否其中有个条件成立:
// 测试是否是周末
if ((current.getDay( ) == 0) || (current.getDay( ) == 6) ) {
trace ("Why are you working on a weekend?");
}
还可以使用 NOT, !, 来测试条件不是真的:
// 检测名字不是Bruce.
if (!(userName == "Bruce")) {
trace ("This application knows only Bruce's birthday.");
}
上面的例子还可以这么写:
if (userName != "Bruce") {
trace ("This application knows only Bruce's birthday.");
}
任何布尔值或能得出布尔结果的表达式都能作为测试表达式:
// 检测如果sprite 是可见的,则输出信息
if (_sprite.visible) {
trace("The sprite is visible.");
}
NOT 运算符经常被用来检测是否是false:
// 检测如果 sprite 是不可见的,则输出信息:
if (!_sprite.visible) {
trace("The sprite is invisible. Set it to visible before trying this action.");
}
NOT 经常和OR 一起用:
// 检测既不是Bruce 有不是 Joey.
if (!((userName == "Bruce") || (userName == "Joey"))) {
trace ("Sorry, but only Bruce and Joey have access to this application.");
}
我要在多个条件中做出决定
解决办法
可以使用逻辑运算符AND (&&), OR (||), 和 NOT (!) 来创建符合条件语句。
讨论
ActionScript中的很多语句都能包含条件表达式。包括 if, while, 和 for 语句,如果测试两个条件都成立可以使用逻辑运算符 AND , &&, (更多细节请看第14章):
// 测试今天是否是3月17号
var current:Date = new Date( );
if (current.getDate( ) == 17 && current.getMonth( ) == 3) {
trace ("Happy Birthday, Bruce!");
}
加入些括号让结构更加清晰:
// Check if today is April 17th.
if ((current.getDate( ) == 17) && (current.getMonth( ) == 3)) {
trace ("Happy Birthday, Bruce!");
}
这里使用了逻辑运算符OR , ||, 来测试是否其中有个条件成立:
// 测试是否是周末
if ((current.getDay( ) == 0) || (current.getDay( ) == 6) ) {
trace ("Why are you working on a weekend?");
}
还可以使用 NOT, !, 来测试条件不是真的:
// 检测名字不是Bruce.
if (!(userName == "Bruce")) {
trace ("This application knows only Bruce's birthday.");
}
上面的例子还可以这么写:
if (userName != "Bruce") {
trace ("This application knows only Bruce's birthday.");
}
任何布尔值或能得出布尔结果的表达式都能作为测试表达式:
// 检测如果sprite 是可见的,则输出信息
if (_sprite.visible) {
trace("The sprite is visible.");
}
NOT 运算符经常被用来检测是否是false:
// 检测如果 sprite 是不可见的,则输出信息:
if (!_sprite.visible) {
trace("The sprite is invisible. Set it to visible before trying this action.");
}
NOT 经常和OR 一起用:
// 检测既不是Bruce 有不是 Joey.
if (!((userName == "Bruce") || (userName == "Joey"))) {
trace ("Sorry, but only Bruce and Joey have access to this application.");
}
- flex as3 执行复杂的条件语句
- flex as3 获得方法的执行结果
- 条件复杂的sql语句查询
- SQL 条件语句的执行顺序
- 化简复杂逻辑,编写紧凑的if条件语句
- where 子语句复杂条件的标准形式
- flex as3 长时间执行一个任务
- SqlDependency执行复杂SQL语句
- 复杂的条件
- 复杂条件的查询
- Python条件语句Python条件语句是通过一条或多条语句的执行结果
- sql语句条件执行顺序
- mybatis 动态sql 根据条件执行相应的语句
- 复杂的update语句
- 复杂的sql语句
- 复杂的sql语句
- 化简复杂逻辑,编写紧凑的if条件语句(二):依据if子句顺序化简条件
- sql语句中如何根据不同的条件,执行不同的where条件
- ASP.NET验证码
- 相似性度量
- app
- 在读研究生应干些什么!
- MultiFieldReportComparator
- flex as3 执行复杂的条件语句
- bug
- 索引失效原因总结
- S5PV210平台在WinCE6下使用512MmDDR(256mx2)
- flex as3 某段时间重复执行一种操作
- BASE,CAP,ACID
- YV12转换到RGB32[]
- Hadoop-0.12.2源代码:Configuration类
- 事务的隔离级别