Adobe Flash AS 2.0 真假

Adobe flash AS 2.0 true and false

我真的没有问题,我只是想了解如何在 adobe flash whit ActionScript 2.0 中使用 "true" 和 "false" 以及我可以使用它做什么?如果你能给我举个例子,请。

首先,不要做AS2。它已经过时 10 年了,这是有原因的。改用 AS3,它更快,结构化(语言和 Flash 平台),并且 AS3 > AS2 以任何可能的方式。

那么,你的问题。 布尔值 值适用于在特定上下文中只有两个可能值的数据。如上午或下午时间、白天或晚上、男性或女性、售罄或可用、可见或隐藏、对或错等

Boolean变量的使用就像说"this data can have only 2 states",它切断了其他可能性并简化了对程序的理解。

最终,条件和循环运算符需要 布尔值 值。在大多数情况下,您提供给这些运算符的 anything 会自动转换为 Boolean 因此最好显式获取 Boolean 数据中的值以保持逻辑清晰。

因此,布尔值 变量用于存储 2 态数据,可用于编程逻辑以控制代码流。

// Conditional 'if..else' block.
if (ConditionA:Boolean)
{
    // Do this if ConditionA is true.
}
else if (ConditionB:Boolean)
{
    // Do this if ConditionB is true while ConditionA is false.
}
else
{
    // Do this if both ConditionA and ConditionB are false.
}

// The 'for' loop.
for (ExpressionA; ConditionA:Boolean; ExpressionB)
{
    // Do the loop while ConditionA is true.
    // Will not run if ConditionA is initially false.
}

// The 'while' loop.
while (ConditionA:Boolean)
{
    // Do the loop while ConditionA is true.
    // Will not run if ConditionA is initially false.
}

// The 'do..while' loop.
do
{
    // Do the loop while ConditionA is true.
    // Will run once even if ConditionA is initially false,
    // because the condition is checked at the end of the loop.
}
while (ConditionA:Boolean);

https://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/Boolean.html#includeExamplesSummary