这到底是什么变种X:*在动作是什么意思? [英] What exactly does var x:* mean in actionscript?

查看:127
本文介绍了这到底是什么变种X:*在动作是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

它有点棘手搜索VAR:*',因为大多数搜索引擎不会找到它

Its a little tricky to search for 'var:*' because most search engines wont find it.

我不清楚到底是什么VAR:*的手段,比起说VAR:对象

I'm not clear exactly what var:* means, compared to say var:Object

我认为这将让我喜欢的对象上设置的任意属性:

I thought it would let me set arbitrary properties on an object like :

var x:*  = myObject;
x.nonExistantProperty = "123";

但是这给了我一个错误:

but this gives me an error :

Property nonExistantProperty not found on x

这是什么*意味着什么?

What does * mean exactly?

编辑:我定了原来的VAR:*正确的VAR X:*。失去了我的互联网连接。

I fixed the original var:* to the correct var x:*. Lost my internet connection

推荐答案

扩展在其他的答案,宣布一些与类型星号的完全的一样离开它无类型。

Expanding on the other answers, declaring something with type asterisk is exactly the same as leaving it untyped.

var x:* = {};
var y = {}; // equivalent

然而,是否允许向对象分配不存在的属性无关与参考的类型,和由该对象是否是一个动态类的实例来确定的问题。

However, the question of whether you are allowed to assign non-existant properties to objects has nothing to do with the type of the reference, and is determined by whether or not the object is an instance of a dynamic class.

例如,由于对象是动态的,字符串不是:

For example, since Object is dynamic and String is not:

var o:Object = {};
o.foo = 1; // fine
var a:* = o;
a.bar = 1; // again, fine

var s:String = "";
s.foo = 1; // compile-time error
var b:* = s;
b.bar = 1; // run-time error

请注意如何你可以随时到对象指定新的属性,无论你用什么样的参考。同样,你永远无法为String指定新的属性,但如果你使用一个类型化的引用,那么这将被捕获由编译器,并与非类型化的参考编译器不知道是否 B 是动态的还是没有,所以在运行时发生的错误。

Note how you can always assign new properties to the object, regardless of what kind of reference you use. Likewise, you can never assign new properties to the String, but if you use a typed reference then this will be caught by the compiler, and with an untyped reference the compiler doesn't know whether b is dynamic or not, so the error occurs at runtime.

顺便说一句,在类型星号DOC参考可以在这里找到:

Incidentally, doc reference on type-asterisk can be found here:

<一个href="http://livedocs.adobe.com/labs/air/1/aslr/specialTypes.html#">http://livedocs.adobe.com/labs/air/1/aslr/specialTypes.html#*

(该标记引擎拒绝,因为星号来linkify的。)

(The markup engine refuses to linkify that, because of the asterisk.)

这篇关于这到底是什么变种X:*在动作是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆