开发者

Pass array collection from flex to javascript function

Is it possible to pass an ArrayCollection object from flex ExternalInterface.call() as a parameter to javascript function?

Flex sample code:

var obj:Object = new Object();
    obj.id = "Id";
    obj.name = "SomeName";
ExternalInterface.call("jsFunction",obj);

JavaScript code:

function jsFunction(flexObj){
  alert('Id::'+flexObj.id+'Name::'+flexObj.name);
}

I am able to get the id and name values in js as they are String objects.

My question is: can I get the arrayCollection object from Flex to JS in the similar way?

obj.list = arrayColl开发者_JAVA百科ectionObj;

If I do in this way I am getting null in JavaScript. How to achieve this?

Any help will be appreciated.


You can't, ListCollections are actually rather complex data structures and they need to be converted to something simpler to get passed to JavaScript. Of course, if you know that all of the contents are simple, you could simply call:

obj.list = arrayCollectionObj.toArray();
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜