3 Replies Latest reply on Jan 19, 2010 3:13 PM by Ned Murphy

    Help... link URL from XML to Flash Action Script 2

    lucgrandgui

      I am trying to link a different URL to each of my files in XML and use this XML in Flash were I created a carousel. In the carousel, when you click on a picture I would like to insert a specific URL. Each picture will have a different URL (http://------------).

      Here are my codes:

       

      XML:

       

      <icons>

      <icon image="icon1.png" tooltip="Planning" />

      <icon image="icon2.png" tooltip="Investments" />

      <icon image="icon3.png" tooltip="Education" />

      <icon image="icon4.png" tooltip="Insurances" />

      <icon image="icon5.png" tooltip="Mortgages" />

      <icon image="icon6.png" tooltip="Retirement" />

      <icon image="icon7.png" tooltip="Business Owner" />

      <icon image="icon8.png" tooltip="Banking" />

      </icons>

       

      Flash Action Script 2:

       

      import mx.utils.Delegate;

      var numOfItems:Number;
      var radiusX:Number = 250;
      var radiusY:Number = 75;
      var centerX:Number = Stage.width/2;
      var centerY:Number = Stage.height/2;
      var speed:Number = 0.01;
      var perspective:Number = 60;
      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[i].attributes.tooltip;
        t.icon.inner.loadMovie(nodes[i].attributes.image);
        t.ref.inner.loadMovie(nodes[i].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()
      {
      ????????????????????????????????????????????????????????????????????????????????????????

      }

      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)/10000;
      }

       

      Thanks so much for the help.