I’m trying to do a loop, and call a javascript function in flex for every loop. The loop only seems to call the javascript once the loop is done… and it only calls it for the last iteration of the loop.
To reproduce the issue do the following:
1. Create a new project in flex
2. Put a button on the form, and make it’s click=”test1();”
3. Create a script block like so
<mx:Script>
<![CDATA[
private function test1():void{
for (var i:int = 0; i < 5; i++){
var u:URLRequest = new URLRequest("javascript:alert(" + "\'test " + i + "\');"); navigateToURL(u,"_self");
trace(i);
}
}
]]>
</mx:Script>
the button calls this very simple function, and theoretically you should get 5 alert boxes, but you don’t you get 1…. i’m curious if these methods can be used like this.
You have to use the call
ExternalInterface.call(”alert”,arg1,arg2,arg3);
That fixed the issue….
navigateToURL is an asynchronous call and doesnt return anything
ExternalInterface is synchronous and can be returned




No user commented in " navigateToURL problems with looping "
Follow-up comment rss or Leave a TrackbackLeave A Reply