I'm trying to read xml field开发者_运维百科s (with actionscript 3), but the problem is that I choose which field to read dynamically. For example, I may need to read test19
or test39
or test12
or anything else.
var value:Number = event.result.test19;
var value:Number = event.result.test39;
var value:Number = event.result.test12;
Is there a way to construct that event.result.test19
part dynamically? Something like the code idea below
var fieldname:String = "test19";
var value:Number = ("event.result." + fieldname) as Number;
I also tried casting as XMLNode ("event.result." + fieldname) as XMLNode
but it didn't work.
Anyone knows how this can be done?
var value:Number = event.result["test19"];
//or
var t:String = "test19";
var value:Number = event.result[t];
obj.something
is same as obj["something"]
and obj[a_var]
where a_var
contains "something."
精彩评论