title: converting Actionscript 2 code into Actionscript 3
body: <p>Recently I followed and made the 3d carousel in AS2, but I'm looking to use it and make it in AS3. Is there any possible way of converting the code so the carousel can work in AS3? </p>
  
  <p>Below is the code for the AS2 carousel:</p>
  
  <pre><code>import mx.utils.Delegate;
  
  var numOfItems:Number;
  var radiusX:Number = 300;
  var radiusY:Number = 75;
  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&lt;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.r.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()
  {
     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)/2500;
  }
  </code></pre>
  
  <p>When I add this code in AS3 I get the following error:</p>
  
  <blockquote>
    <p>Scene 1, Layer 'Layer 1', Frame 1, Line 1 1172: Definition mx.utils:Delegate could not be found.
    Scene 1, Layer 'Layer 1', Frame 1, Line 1 1172: Definition mx.utils:Delegate could not be found.
    Scene 1, Layer 'Layer 1', Frame 1, Line 41 1120: Access of undefined property Delegate.
    Scene 1, Layer 'Layer 1', Frame 1, Line 6 1119: Access of possibly undefined property width through a reference with static type Class.
    Scene 1, Layer 'Layer 1', Frame 1, Line 7 1119: Access of possibly undefined property height through a reference with static type Class.</p>
  </blockquote>
  
  <p>I'm quite new to AS2 and AS3 but after some research I understand that <code>import mx.utils.Delegate;</code> is no longer need in AS3 as it already has delegate and they are already built in so in the code so I delete the delegate which are line 1 and line 41 and got two errors:</p>
  
  <blockquote>
    <p>Scene 1, Layer 'Layer 1', Frame 1, Line 6 1119: Access of possibly undefined property width through a reference with static type Class.
    Scene 1, Layer 'Layer 1', Frame 1, Line 7 1119: Access of possibly undefined property height through a reference with static type Class.</p>
  </blockquote>
  
  <p>Now I cant figure out what to do so can someone help me convert this code from AS2 to AS3?</p>