开发者

Pass array collection from flex to javascript function

开发者 https://www.devze.com 2023-03-22 07:41 出处:网络
Is it possible to pass an ArrayCollection object from flex ExternalInterface.call() as a parameter 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

精彩评论

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