AS3 URLRequest in for Loop problem

Posted by Adrian on Stack Overflow See other posts from Stack Overflow or by Adrian
Published on 2010-06-11T23:20:51Z Indexed on 2010/06/11 23:32 UTC
Read the original article Hit count: 336

Filed under:
|
|

Hi guys,

I read some data from a xml file, everything works great besides urls. I can't figure what's the problem with the "navigateURL" function or with the eventListener... on which square I click it opens the last url from the xml file

for(var i:Number = 0; i <= gamesInput.game.length() -1; i++)
 {
  var square:square_mc = new square_mc();

  //xml values
  var tGame_name:String   = gamesInput.game.name.text()[i];//game name
  var tGame_id:Number     = gamesInput.children()[i].attributes()[2].toXMLString();//game id
  var tGame_thumbnail:String  = thumbPath + gamesInput.game.thumbnail.text()[i];//thumb path
  var tGame_url:String     = gamesInput.game.url.text()[i];//game url

  addChild(square);
  square.tgname_txt.text = tGame_name;
  square.tgurl_txt.text = tGame_url;

  //load & attach game thumb
  var getThumb:URLRequest = new URLRequest(tGame_thumbnail);
  var loadThumb:Loader = new Loader();
   loadThumb.load(getThumb);
   square.addChild(loadThumb);
  //
  square.y = squareY;
  square.x = squareX;
  squareX += square.width + 10;

  square.buttonMode = true;
  this.addEventListener(MouseEvent.CLICK, navigateURL);

 }

 function navigateURL(event:MouseEvent):void
 { 
  var url:URLRequest = new URLRequest(tGame_url);
  navigateToURL(url, "_blank");
  trace(tGame_url);
 }

Many thanks!

© Stack Overflow or respective owner

Related posts about for-loop

Related posts about as3