Maybe I am not getting what problems you are facing, but what you want is
still possible without any special serialization.  In case you are testing
in Chrome, it might not work because of its sandbox restrictions.  Try this
in IE or Firefox and let me know what happens.

Everything gets sent as an Object to the JavaScript function.  You just
need to know the structure of the object and parse it in JS.

AS:
protected function application1_initializeHandler(event:FlexEvent):void
{
var employees:Array = [
{ firstName:"Joe", lastName:"Doe", age:25, isFullTime:true},
{ firstName:"Ann", lastName:"Cavanah", age:28, isFullTime:false}
];
var ac:ArrayCollection = new ArrayCollection(employees);
 var payload:Array = [
{firstName:"Om", lastName:"Muppirala", children:ac},
{firstName:"Om", lastName:"Muppirala", children:ac},
{firstName:"Om", lastName:"Muppirala", children:ac}
];
 ExternalInterface.call("passDataToJS", payload);
}

JS:

            function passDataToJS(obj)
            {
            for(var i in obj)
            {
            var children = obj[i].children;
            for(var j in children.source)
            {
             console.log(children.source[j].firstName + ", " +
children.source[j].lastName + ", " + children.source[j].age);
             if(children.source[j].isFullTime)
             {
             console.log("Employee is fulltime");
             }
             else
             {
             console.log("Employee is not fulltime");
             }
            }

            }
            }

Console output:

Joe, Doe, 25
Employee is fulltime
Ann, Cavanah, 28
Employee is not fulltime
Joe, Doe, 25
Employee is fulltime
Ann, Cavanah, 28
Employee is not fulltime
Joe, Doe, 25
Employee is fulltime
Ann, Cavanah, 28
Employee is not fulltime

Thanks,
Om

On Tue, Jun 16, 2015 at 11:22 AM, olegkon <oleg...@gmail.com> wrote:

> But remember, what I need to pass to JS is an Array of those value objects
> (each of which has a bunch of String's as well as that
> children:ArrayCollection) ?
>
> myArray = [ {firstName:"John", lastName:"Doe", children:ArrayCollection},
> ... ]
>
> And yes, I tried that originally - to pass that array to ExternalInterface
> -
> nothing happened.
>
> And even if I did JSON.stringify as String or Object - did not work
> until I removed AC from there.
>
> I guess, I need to use replacer function - somehow pass children.source,
> just not sure about serializers, etc.
>
> Please advise.
>
>
>
>
>
> --
> View this message in context:
> http://apache-flex-users.2333346.n4.nabble.com/Fwd-Adding-JS-graph-to-Flex-project-tp10537p10599.html
> Sent from the Apache Flex Users mailing list archive at Nabble.com.
>

Reply via email to