开发者

ActionScript 3 Object to name value string

In a Flex application I am trying to turn an Object into a QueryString such as name1=value1&name2=value2... But I am having trouble getting the names of the Objects children. How do I enumerate the names instead of the value开发者_运维知识库s?

Thanks


I'm guessing you're doing a for each(in) loop. Just do a normal for(in) loop and you'll get the names instead of the values:

for(var name:String in obj) {
  var value:* = obj[name];
  // do whatever you need
}


Ok, first off, if you need that query string to actually query a server, you don't really need to get it yourself as this code will query the server for you

protected function callSerivce():void
{
    var o:Object = new Object();
    o.action = "loadBogusData";
    o.val1 = "dsadasd";
    service.send(o);
}

<mx:HTTPService id="service" url="http://www.somewhere.com/file.php" method="GET" showBusyCursor="true"/>

Will make a call to the server like this: http://www.somewhere.com/file.php?action=loadBogusData&val1=dsadasd

But in case you really want to analyze the object by hand, try using ObjectUtil.getClassInfo, it returns a lot of information including all the fields (read more on LiveDocs).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜