1 Reply Latest reply on Oct 13, 2009 4:55 AM by teocomi

    use navigateToURL  in a loop

      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

      private function test1():void{
      for (var i:int = 0; i < 5; i++){
      var u:URLRequest = new URLRequest("javascript:alert(" + "\'test " + i + "\');");


      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.
        • 1. Re: use navigateToURL  in a loop

          have a look here: http://livedocs.adobe.com/flex/gumbo/html/WS2db454920e96a9e51e63e3d11c0bf626ae-7fe8.html


               import flash.net.navigateToURL;
               private var listingData:Array=[

               private function openWindows(n: Number):void {
                  if (n < listingData.length) {
                     navigateToURL(new URLRequest(listingData[n]), '_blank');
                     callLater(callLater, [openWindows, [n+1]]);
            <s:Button label="Click Me" click="openWindows(0)"/>