actionscript-3 - 声明为 * (star) 类型的 Actionscript 变量

标签 actionscript-3 variables syntax

我在某处看到以下声明-

var someVariable:*;

为什么 someVariable 被声明为 * (star) 类型?这样声明有什么用?

最佳答案

*之间的实际区别和 Object*可以 undefinedObject不能。
文档有 this说:

Specifies that a property is untyped. Use of the asterisk symbol for a type annotation is equivalent to using no type annotation. Expressions that read from untyped properties are considered untyped expressions. Use of untyped expressions or properties is recommended in the following circumstances:

  • When you want to defer type checking to runtime. You can use an untyped property or expression to circumvent compile-time type checking in strict mode. Note, however, that runtime type checking of assignment statements occurs whether you use strict mode or not.

  • When you want to store the value undefined in a property. Unlike previous versions of ActionScript, the value undefined is not a member of the Object data type. You must use an untyped property to store the value undefined.

关于actionscript-3 - 声明为 * (star) 类型的 Actionscript 变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4103377/

相关文章:

javascript - JavaScript 函数能否检测调用它的 Flash DOM 对象?

linux - 我如何使用一组指令的输出来创建一个新变量?

variables - Makefile 变量初始化和导出

syntax - lua (Syntax) : Calling a function that returns more than 1 value, 并使用这些值作为参数,但没有额外的变量赋值行?

c - 使用 : operator in C

syntax - OCaml 文字负数?

javascript - Flash Player 通知浏览器正在关闭++

flash - AS3 中使用透明 PNG 进行 mask

php - 如何将变量从 PHP 传递到 Flash (ActionScript 3)

php - PHP丢失变量数据