This works fine for me:
AS:
protected function application1_initializeHandler(event:FlexEvent):void
{
var employees:Array = [
{ firstName:"Joe", lastName:"Doe", age:25},
{ firstName:"Ann", lastName:"Cavanah", age:28}
];
ExternalInterface.call("passDataToJS", employees);
}
JS:
function passDataToJS(obj)
{
for(var i in obj)
{
console.log(obj[i].firstName + ", " + obj[i].lastName + ", " +
obj[i].age);
}
}
In the console:
Joe, Doe, 25
Ann, Cavanah, 28
On Mon, Jun 15, 2015 at 12:16 PM, OmPrakash Muppirala <[email protected]>
wrote:
> On Mon, Jun 15, 2015 at 8:48 AM, olegkon <[email protected]> wrote:
>
>> Let me give you a simplified version of what I tried.
>> Suppose I have an array of Employee objects.
>>
>> class Employee {
>> firstName:String;
>> lastName:String;
>> age:Number;
>> }
>>
>> var employees:Array = [
>> { firstName:"Joe", lastName:"Doe", age:25},
>> { firstName:"Ann", lastName:"Cavanah", age:28}
>> ];
>>
>> var empStr:String = JSON.stringify(employees);
>> ExtrnalInterface.call("passDataToJS", empStr);
>>
>> I am new to JSON, so not sure I am converting it right.
>>
>>
> Thanks for the code. How is the javascript function looking?
>
> Om
>
>
>>
>>
>> --
>> View this message in context:
>> http://apache-flex-users.2333346.n4.nabble.com/Fwd-Adding-JS-graph-to-Flex-project-tp10537p10585.html
>> Sent from the Apache Flex Users mailing list archive at Nabble.com.
>>
>
>