2 Replies Latest reply on Apr 25, 2006 9:23 AM by gjuddy

    problem with XML and getURL

    gjuddy
      Hi Everybody,

      Here is my problem...I'm building a horizontal sliding menu on the fly from an XML doc featuring thumbnails and text. I've got 10 childnodes in my XML doc that are supposed to load as 10 movieclips featuring 10 separate and different thumbnails...which they do...the problem arises when I try to apply links to the movieclips from url's also defined in the XML doc. I can trace the urls no problem and the following code gives me a list of my 10 urls:

      var link_to:Array = [featuresXML.childNodes .childNodes[4].firstChild];
      trace(link_to);

      When I try to apply them to the movieclips though:

      postersMC.itemsMC[name].mc_buttonPicture.onRelease = function() {
      trace(link_to);

      I get only the last link from the list of 10...and it is applied to all the movieclips...so no matter which one I click on, I get the same link.

      I think it has something to do with the array and that I'm not calling it properly in my onRelease function...I dunno...any suggestions would be much appreciated. Let me know if you would like to see more of the code...I'll happily post the whole thing if it'll help. This is the last thing to do for this project and I'm really stumped.

      Thanks in advance.
        • 1. Re: problem with XML and getURL
          Peter Lorent Level 2
          The for loop won't assign the onRelease untill it reaches the last loop. Assign the event handlers in a seperate function:

          function SetRelease(target_mc:MovieClip,url:String):Void{
          target_mc.onRelease=function():Void{
          getURL(url);
          };
          }

          and call the function from your for loop passing the thumb and the link_to
          • 2. Re: problem with XML and getURL
            gjuddy Level 1
            Thanks for your response LuigiL. I actually found a solution and it ended up being one line of code.

            postersMC.itemsMC[name].mc_buttonPicture.myLink = link_to;
            postersMC.itemsMC[name].mc_buttonPicture.onRelease = function() {
            trace(this.myLink);

            Anyway, thanks again for taking the time to respond.