0

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 = arrayCollectionObj;

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

Any help will be appreciated.

1 Answer 1

3

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();
Sign up to request clarification or add additional context in comments.

2 Comments

if I convert and pass the array to js, how can I read the values in js?
The docs say that you can just read it as an array.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.