开发者

ActionScript Reading A Vector's DataType?

开发者 https://www.devze.com 2022-12-31 16:27 出处:网络
is it possible to read the datatype of a vector? var vec:Vector.&开发者_如何学运维lt;int> = new Vector.<int>;

is it possible to read the datatype of a vector?

var vec:Vector.&开发者_如何学运维lt;int> = new Vector.<int>;
trace(the datatype of vec);
//ideally this would output 'int'


You could use describeType function who will return you an xml describing the type of your vec, and then get the type name that is for a vector enclosed between < and > or use the function getQualifiedClassName that will return the name of your class.

        var name:String = describeType(vec).@name.toString();
        var type:String = name.substring(name.indexOf("<")+1, name.length-1);
        trace(type);


        var name:String = getQualifiedClassName(vec);
        var type:String = name.substring(name.indexOf("<")+1, name.length-1);
        trace(type);
0

精彩评论

暂无评论...
验证码 换一张
取 消