开发者

Dynamically setting xml by string concatenation

开发者 https://www.devze.com 2023-01-05 17:54 出处:网络
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 any

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."

0

精彩评论

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