29 Replies Latest reply on Jun 7, 2007 1:42 PM by hciguy

    Please help

    justtech
      I have a flash element that is a "carousel" of logos for my website. I've got the logos pulled from an .xml file but not sure how to make the logos clickable or hyperlinked to an outside website. Anyone have a direction that they can point me?
        • 1. Please help
          nITiNkIlLeRmEeRuT
          if you are loading logo in a movieclip use onRelease event to make them clickable

          use it to open link
          getURL

          search help for more information
          • 2. Re: Please help
            justtech Level 1
            In the .xml file? Because you don't see the images in Flash until you play movie and then it loads from the .xml file.
            • 3. Re: Please help
              hciguy Level 1
              You're loading the images into a movie clip object, correct? Then you'll need to have appropriate Actionscript that creates event handlers for those movie clips. You'll probably need to have the URL in the xml, load the URL in, then make onRelease events which do a getURL to the URL loaded from the XML.....

              That's my take on it.
              • 4. Re: Please help
                justtech Level 1
                Appropriate Actionscript... that's where I get lost. Does anyone know where I can go for a tutorial on .xml within flash and URLs? Or if I upload the files in a .zip file can someone take a look at this?
                • 5. Re: Please help
                  hciguy Level 1
                  Well how are you loading from the XML right now without Actionscript? You must have written some Actionscript to load in the XML for your logos, right?

                  Thanks.
                  • 6. Re: Please help
                    hciguy Level 1
                    Well how are you loading from the XML right now without Actionscript? You must have written some Actionscript to load in the XML for your logos, right?

                    Thanks.
                    • 7. Re: Please help
                      justtech Level 1
                      Correct. I just don't know what the "Appropriate ActionScript" is to call the .xml file for a url.
                      • 8. Re: Please help
                        hciguy Level 1
                        Okay so right now, you load in each node of your XML file? Each node denotes the logo file? Say you have the following node:

                        <logoitem file="mylogo.gif" url="www.somewhere.com" />

                        Then load that XML into Flash as you are doing and get those attributes (i.e. @file and @url). Then use the @url name to attach a new event handler onto your movie clip object for that respective logo. Make sense?

                        I don't know where you're confused...
                        • 9. Re: Please help
                          justtech Level 1
                          I'm not sure why I am having problems with this either... but this is what the action script looks like:

                          import mx.utils.Delegate;

                          var numOfItems:Number;
                          var radiusX:Number = 210;
                          var radiusY:Number = 55;
                          var centerX:Number = Stage.width / 2;
                          var centerY:Number = Stage.height / 2;
                          var speed:Number = 0.05;
                          var perspective:Number = 130;
                          var home:MovieClip = this;

                          var tooltip:MovieClip = this.attachMovie("tooltip","tooltip",10000);
                          tooltip._alpha = 0;

                          var xml:XML = new XML();
                          xml.ignoreWhite = true;

                          xml.onLoad = function()
                          {
                          var nodes = this.firstChild.childNodes;
                          numOfItems = nodes.length;
                          for(var i=0;i<numOfItems;i++)
                          {
                          var t = home.attachMovie("item","item"+i,i+1);
                          t.angle = i * ((Math.PI*2)/numOfItems);
                          t.onEnterFrame = mover;
                          t.toolText = nodes .attributes.tooltip;
                          t.icon.inner.loadMovie(nodes
                          .attributes.image);
                          t.r.inner.loadMovie(nodes .attributes.image);
                          t.icon.onRollOver = over;
                          t.icon.onRollOut = out;
                          t.icon.onRelease = released;
                          }
                          }

                          function over()
                          {
                          home.tooltip.tipText.text = this._parent.toolText;
                          home.tooltip._x = this._parent._x;
                          home.tooltip._y = this._parent._y - this._parent._height/2;
                          home.tooltip.onEnterFrame = Delegate.create(this,moveTip);
                          home.tooltip._alpha = 100;
                          }

                          function out()
                          {
                          delete home.tooltip.onEnterFrame;
                          home.tooltip._alpha = 0;
                          }

                          function released()
                          {
                          trace(this._parent.toolText);
                          }

                          function moveTip()
                          {
                          home.tooltip._x = this._parent._x;
                          home.tooltip._y = this._parent._y - this._parent._height/2;
                          }

                          xml.load("icons.xml");

                          function mover()
                          {
                          this._x = Math.cos(this.angle) * radiusX + centerX;
                          this._y = Math.sin(this.angle) * radiusY + centerY;
                          var s = (this._y - perspective) /(centerY+radiusY-perspective);
                          this._xscale = this._yscale = s*100;
                          this.angle += this._parent.speed;
                          this.swapDepths(Math.round(this._xscale) + 100);
                          }

                          this.onMouseMove = function()
                          {
                          speed = (this._xmouse-centerX)/12500;
                          }

                          and this is what one line of the .xml file looks like:
                          <icon image="latitude.swf" tooltip="Latitude Resteraunt" />
                          • 10. Re: Please help
                            hciguy Level 1
                            You wrote this AS? I am working under the assumption that you understand AS....

                            for(var i=0;i<numOfItems;i++)
                            {
                            var t = home.attachMovie("item","item"+i,i+1);
                            t.angle = i * ((Math.PI*2)/numOfItems);
                            t.onEnterFrame = mover;
                            t.toolText = nodes.attributes.tooltip;
                            t.icon.inner.loadMovie(nodes.attributes.image);
                            t.r.inner.loadMovie(nodes.attributes.image);
                            t.icon.onRollOver = over;
                            t.icon.onRollOut = out;
                            t.icon.onRelease = released;
                            }
                            }

                            In this for loop, it looks like you're assigning a function to the onRelease state for each item in your XML file? Correct if I am wrong but t.icon.onRelease is a function called when the click is released on that movie clip? Then what you need to do is make an attribute in each XML node called "url" or whatever you'd like to call it. Then in your for loop, read the url attribute and assign it to a variable for each instance of your movie clip. Then use that variable in a getURL for the onRelease function of each movie clip....

                            You know what I mean?
                            • 11. Re: Please help
                              justtech Level 1
                              Oh no, I didn't write this and I have just the basic knowledge of actionscript. I got this script off of hotscripts.com and I am trying to get it modified to what I need. I appreciate you taking the time to help me on this. So as far as what you wrote last.. I'm lost. I apologize about this.
                              • 12. Re: Please help
                                hciguy Level 1
                                Try this maybe....

                                for(var i=0;i<numOfItems;i++)
                                {
                                var t = home.attachMovie("item","item"+i,i+1);
                                t.angle = i * ((Math.PI*2)/numOfItems);
                                t.onEnterFrame = mover;
                                t.toolText = nodes.attributes.tooltip;
                                t.url = nodes.attributes.url;
                                t.icon.inner.loadMovie(nodes.attributes.image);
                                t.r.inner.loadMovie(nodes.attributes.image);
                                t.icon.onRollOver = over;
                                t.icon.onRollOut = out;
                                t.icon.onRelease = released;
                                }
                                }

                                Then later in your released function:

                                function released()
                                {
                                trace(this._parent.toolText);
                                getURL(this.url);
                                }

                                Hopefully you know how to use getURL? If that doesn't work tweak it so it loads the url based on this.url. You'll also need to add url attribute to your xml, so your xml would be <logoitem file="mylogo.gif" url="www.somewhere.com" />

                                • 13. Re: Please help
                                  justtech Level 1
                                  That has definetly gotten me closer. There is now movement when I click on one of the logos. Problem is, when I click on it, it says "The requested URL /Flash%20carousel/undefined does not exist." It does that with all of the logos. I only put a url in the .xml file for just one of the logos for now while I'm trying to understand what's happening. So is it calling the .xml file for the url? How do I make it look at the .xml file for the specific url that I need as each logo will have a different url?
                                  • 14. Re: Please help
                                    hciguy Level 1
                                    Copy to me in here your AS code and your XML file contents

                                    (PS I have a meeting so it may be a bit before I can get back to you)
                                    • 15. Re: Please help
                                      justtech Level 1
                                      AS code:
                                      import mx.utils.Delegate;

                                      var numOfItems:Number;
                                      var radiusX:Number = 210;
                                      var radiusY:Number = 55;
                                      var centerX:Number = Stage.width / 2;
                                      var centerY:Number = Stage.height / 2;
                                      var speed:Number = 0.05;
                                      var perspective:Number = 130;
                                      var home:MovieClip = this;

                                      var tooltip:MovieClip = this.attachMovie("tooltip","tooltip",10000);
                                      tooltip._alpha = 0;

                                      var xml:XML = new XML();
                                      xml.ignoreWhite = true;

                                      xml.onLoad = function()
                                      {
                                      var nodes = this.firstChild.childNodes;
                                      numOfItems = nodes.length;
                                      for(var i=0;i<numOfItems;i++)
                                      {
                                      var t = home.attachMovie("item","item"+i,i+1);
                                      t.angle = i * ((Math.PI*2)/numOfItems);
                                      t.onEnterFrame = mover;
                                      t.toolText = nodes .attributes.tooltip;
                                      t.url = nodes.attributes.url;
                                      t.icon.inner.loadMovie(nodes
                                      .attributes.image);
                                      t.r.inner.loadMovie(nodes .attributes.image);
                                      t.icon.onRollOver = over;
                                      t.icon.onRollOut = out;
                                      t.icon.onRelease = released;
                                      }
                                      }

                                      function over()
                                      {
                                      home.tooltip.tipText.text = this._parent.toolText;
                                      home.tooltip._x = this._parent._x;
                                      home.tooltip._y = this._parent._y - this._parent._height/2;
                                      home.tooltip.onEnterFrame = Delegate.create(this,moveTip);
                                      home.tooltip._alpha = 100;
                                      }

                                      function out()
                                      {
                                      delete home.tooltip.onEnterFrame;
                                      home.tooltip._alpha = 0;
                                      }

                                      function released()
                                      {
                                      trace(this._parent.toolText);
                                      getURL("this.url", "_blank");
                                      }

                                      function moveTip()
                                      {
                                      home.tooltip._x = this._parent._x;
                                      home.tooltip._y = this._parent._y - this._parent._height/2;
                                      }

                                      xml.load("icons.xml");

                                      function mover()
                                      {
                                      this._x = Math.cos(this.angle) * radiusX + centerX;
                                      this._y = Math.sin(this.angle) * radiusY + centerY;
                                      var s = (this._y - perspective) /(centerY+radiusY-perspective);
                                      this._xscale = this._yscale = s*100;
                                      this.angle += this._parent.speed;
                                      this.swapDepths(Math.round(this._xscale) + 100);
                                      }

                                      this.onMouseMove = function()
                                      {
                                      speed = (this._xmouse-centerX)/12500;
                                      }

                                      .XML Contents
                                      <icons>

                                      <icon image="heritage.png" tooltip="Heritage Insurance" url=" http://www.justtechonline.com"/>

                                      <icon image="ja.png" tooltip="Junior Achievement" />

                                      <icon image="latitude.swf" tooltip="Latitude Resteraunt" />

                                      <icon image="dougal.png" tooltip="Dougal Maguire's"/>

                                      <icon image="phoenix.png" tooltip="The Phoenix Inn" />

                                      <icon image="image.png" tooltip="Image Specialties" />

                                      <icon image="question.png" tooltip="Your Logo Here" />

                                      </icons>
                                      • 16. Re: Please help
                                        hciguy Level 1
                                        Ok real quick....

                                        First, put a trace in when you do the url attribute in the for loop. So do this for your for loop:

                                        for(var i=0;i<numOfItems;i++)
                                        {
                                        var t = home.attachMovie("item","item"+i,i+1);
                                        t.angle = i * ((Math.PI*2)/numOfItems);
                                        t.onEnterFrame = mover;
                                        t.toolText = nodes.attributes.tooltip;
                                        t.url = nodes.attributes.url;
                                        trace("Here is the url to make sure I have it right in here: " + nodes.attributes.url);
                                        t.icon.inner.loadMovie(nodes.attributes.image);
                                        t.r.inner.loadMovie(nodes.attributes.image);
                                        t.icon.onRollOver = over;
                                        t.icon.onRollOut = out;
                                        t.icon.onRelease = released;
                                        }
                                        }

                                        Okay and then don't put the var in quotes in the onRelease:

                                        function released()
                                        {
                                        trace(this._parent.toolText);
                                        getURL(this.url, _blank);
                                        }

                                        Finally, put a url in each XML element.

                                        Try it.
                                        • 17. Re: Please help
                                          justtech Level 1
                                          Okay, I did exactly what you said. As soon as I play the movie, it gives me 7 (number of logos I have) of the "Trace" sentences in the output with "=undefined". Then when I click on one of the logos, in the output window, I get the Tooltip name of the icon in the output. A new tab opens up in Firefox and says the same thing, "Can't find the file" "undefined".
                                          • 18. Re: Please help
                                            hciguy Level 1
                                            Hmmm.....maybe cause url may be reserved?

                                            Try renaming url to "website" or something in your AS and XML....

                                            t.website = nodes.attributes.website;
                                            trace("Here is the url to make sure I have it right in here: " + nodes.attributes.website);


                                            Make sure you change url attribute to website in XML
                                            • 19. Re: Please help
                                              justtech Level 1
                                              exact same. I'm sorry bro.. what a pain this is.
                                              • 20. Re: Please help
                                                hciguy Level 1
                                                Change

                                                getURL("this.url", "_blank");

                                                Into

                                                getURL(this._parent.website, "_blank");

                                                If you knew some AS this wouldn't be hard...I just can't load it up and try stuff here...

                                                If that doesn't work, repaste the whole code back to me so I can see exactly what you ran....and your XML

                                                Thanks
                                                • 21. Re: Please help
                                                  justtech Level 1
                                                  Output: "Here is the url to make sure I have it right here:undefined"
                                                  Firefox says "Firefox can't find the file at "myfilepath"/this._parent.website.

                                                  ActionScript:
                                                  import mx.utils.Delegate;

                                                  var numOfItems:Number;
                                                  var radiusX:Number = 210;
                                                  var radiusY:Number = 55;
                                                  var centerX:Number = Stage.width / 2;
                                                  var centerY:Number = Stage.height / 2;
                                                  var speed:Number = 0.05;
                                                  var perspective:Number = 130;
                                                  var home:MovieClip = this;

                                                  var tooltip:MovieClip = this.attachMovie("tooltip","tooltip",10000);
                                                  tooltip._alpha = 0;

                                                  var xml:XML = new XML();
                                                  xml.ignoreWhite = true;

                                                  xml.onLoad = function()
                                                  {
                                                  var nodes = this.firstChild.childNodes;
                                                  numOfItems = nodes.length;
                                                  for(var i=0;i<numOfItems;i++)
                                                  {
                                                  var t = home.attachMovie("item","item"+i,i+1);
                                                  t.angle = i * ((Math.PI*2)/numOfItems);
                                                  t.onEnterFrame = mover;
                                                  t.toolText = nodes .attributes.tooltip;
                                                  t.website = nodes.attributes.website;
                                                  trace("Here is the url to make sure I have it right here:" + nodes.attributes.website);
                                                  t.icon.inner.loadMovie(nodes
                                                  .attributes.image);
                                                  t.r.inner.loadMovie(nodes .attributes.image);
                                                  t.icon.onRollOver = over;
                                                  t.icon.onRollOut = out;
                                                  t.icon.onRelease = released;
                                                  }
                                                  }

                                                  function over()
                                                  {
                                                  home.tooltip.tipText.text = this._parent.toolText;
                                                  home.tooltip._x = this._parent._x;
                                                  home.tooltip._y = this._parent._y - this._parent._height/2;
                                                  home.tooltip.onEnterFrame = Delegate.create(this,moveTip);
                                                  home.tooltip._alpha = 100;
                                                  }

                                                  function out()
                                                  {
                                                  delete home.tooltip.onEnterFrame;
                                                  home.tooltip._alpha = 0;
                                                  }

                                                  function released()
                                                  {
                                                  trace(this._parent.toolText);
                                                  getURL("this._parent.website",_blank);
                                                  }

                                                  function moveTip()
                                                  {
                                                  home.tooltip._x = this._parent._x;
                                                  home.tooltip._y = this._parent._y - this._parent._height/2;
                                                  }

                                                  xml.load("icons.xml");

                                                  function mover()
                                                  {
                                                  this._x = Math.cos(this.angle) * radiusX + centerX;
                                                  this._y = Math.sin(this.angle) * radiusY + centerY;
                                                  var s = (this._y - perspective) /(centerY+radiusY-perspective);
                                                  this._xscale = this._yscale = s*100;
                                                  this.angle += this._parent.speed;
                                                  this.swapDepths(Math.round(this._xscale) + 100);
                                                  }

                                                  this.onMouseMove = function()
                                                  {
                                                  speed = (this._xmouse-centerX)/12500;
                                                  }


                                                  XML:
                                                  <icons>

                                                  <icon image="heritage.png" tooltip="Heritage Insurance" website=" http://www.heritageins.com"/>

                                                  <icon image="ja.png" tooltip="Junior Achievement" website=" http://www.ja.com" />

                                                  <icon image="latitude.swf" tooltip="Latitude Resteraunt" website=" http://www.latitude-westend.com" />

                                                  <icon image="dougal.png" tooltip="Dougal Maguire's" website=" http://www.dougalmaguires.com" />

                                                  <icon image="phoenix.png" tooltip="The Phoenix Inn" website=" http://www.thephoenixgreenvillesinn.com" />

                                                  <icon image="image.png" tooltip="Image Specialties" website="www.image.com" />

                                                  <icon image="question.png" tooltip="Your Logo Here" website="www.youronestophosting.com" />

                                                  </icons>
                                                  • 22. Re: Please help
                                                    hciguy Level 1
                                                    Try changing

                                                    t.website = nodes.attributes.website;

                                                    To

                                                    t.thisUrl = nodes.attributes.website;
                                                    trace("Here is to see if I have the website here: " + this.firstChild.childNodes .attributes.website);

                                                    I don;'t know why it wouldn't work...looks fine to me. If it gets the tooltext attribute don't see why it wouldn't get the website one....

                                                    And no quotes on this._parent.thisUrl in getURL

                                                    • 23. Re: Please help
                                                      hciguy Level 1
                                                      Crap it screwed up when I posted it:

                                                      t.thisUrl = this.firstChild.childNodes .attributes.website;
                                                      trace("Here is to see if I have the website here: " + this.firstChild.childNodes
                                                      .attributes.website);
                                                      • 24. Re: Please help
                                                        hciguy Level 1
                                                        Grrrrr it keeps taking my i out of it lol

                                                        Try changing

                                                        t.website = nodes.attributes.website;

                                                        To

                                                        t.thisUrl = this.firstChild.childNodes\[i\].attributes.website;
                                                        trace("Here is to see if I have the website here: " + this.firstChild.childNodes\[i\].attributes.website);

                                                        You have to take out the \ in there cause I put them in so the brackets would show. Actually, there are brackets in it too, huh? You need to use the same format as they use for t.toolText ... so if that has i in brackets make sure the syntax is same for website one. That is why it isn't working because when you paste to me the b rackets are out...

                                                        I don;'t know why it wouldn't work...looks fine to me. If it gets the tooltext attribute don't see why it wouldn't get the website one....

                                                        And no quotes on this._parent.thisUrl in getURL

                                                        Actually, do you
                                                        • 25. Re: Please help
                                                          justtech Level 1
                                                          I have taken what you have given me and implemented it. I had the same outputs and firefox results. then I read on and it said that it needed to match the tooltip... so I did that and it changed the output to say the url after the trace sentence instead of undefined. But, when you click on the logos Firefox gives the same undefined rusults.

                                                          What I have now in actionscript:
                                                          for(var i=0;i<numOfItems;i++)
                                                          {
                                                          var t = home.attachMovie("item","item"+i,i+1);
                                                          t.angle = i * ((Math.PI*2)/numOfItems);
                                                          t.onEnterFrame = mover;
                                                          t.toolText = nodes[i\].attributes.tooltip;
                                                          t.thisUrl = nodes[i\].attributes.website;
                                                          trace("Here is the url to make sure I have it right here:" + nodes[i\].attributes.website);
                                                          t.icon.inner.loadMovie(nodes[i\].attributes.image);
                                                          t.r.inner.loadMovie(nodes[i\].attributes.image);
                                                          t.icon.onRollOver = over;
                                                          t.icon.onRollOut = out;
                                                          t.icon.onRelease = released;
                                                          }
                                                          }

                                                          *I have added a "\" to all the "i" in brackets so it wouldn't go italics.
                                                          I did not change anything in the .xml file.
                                                          • 26. Re: Please help
                                                            justtech Level 1
                                                            404 Not Found
                                                            The requested URL /Flash%20carosel/undefined does not exist.

                                                            This is what Firefox spits back.
                                                            • 27. Re: Please help
                                                              hciguy Level 1
                                                              What does your getURL look like in your released function?

                                                              It should look like:

                                                              getURL(this._parent.thisURL,_blank);

                                                              No quotes around this._parent.thisURL
                                                              • 28. Re: Please help
                                                                justtech Level 1
                                                                that fixed it... the bottom one under released function was getUrl and the top was getURL ... thank you SOOO much for your help. If you ever need anything that maybe I can offer you, please let me know. I appreciate all your help.
                                                                • 29. Re: Please help
                                                                  hciguy Level 1
                                                                  You're welcome. Glad I could help.