如何知道一个对象在 AS3 中是否是动态的 [英] How to know if an object is dynamic in AS3

查看:20
本文介绍了如何知道一个对象在 AS3 中是否是动态的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Action Script 3 中,您可以编写一个定义动态对象的类(MovieClip 和 Object 是两个示例),该对象可以在运行时修改.我想知道是否有某种方法(当然是在运行时)可以知道某个对象是否是动态的.

In Action Script 3, you can write a class that defines a dynamic object (MovieClip and Object are two examples), this objects can be modified in run-time. What I want to know if is there some way (in run-time, of course) to know if certain object is dynamic or not.

PS:没有做这样的事情:

PS: Without making something like this:

function isDynamic(object) {
    try {
        object.newProperty = 'someValue'
    } catch (e) {
        return false
    }
    return true
}

推荐答案

CookieOfFortune 思路是对的,可惜代码本身有问题,isDynamic是一个属性,返回值会是一个值为String的XMLList反映真或假值,而不是直接返回布尔值的子节点.它应该看起来更像这样:

CookieOfFortune has the right idea, but unfortunately the code itself has problems, isDynamic is an attribute, and the returned value will be a XMLList with a value of a String that reflects a true or false value, not a child node that directly returns a Boolean. It should look more like this:

function isDynamic(object) : Boolean
{
    var type:XML = describeType(object);
    return type.@isDynamic.toString() == "true";
}

这篇关于如何知道一个对象在 AS3 中是否是动态的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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