5 Replies Latest reply on Nov 23, 2010 11:31 PM by museo madrid

    Convert AS 3.0 to AS 2.0

    museo madrid

      Hello,

       

      I know I am goings backward from AS 3 to AS 2, but it is needed to happen (please sorry for my bad English).

       

      I found cool drag and drop but is in AS 3 and I need to convert to AS 2. Could anyone please help me? I have given the AS3 below.

       

      Thank you so much!!!

       

       

       

       

       

      var startX:Number;
      var startY:Number;
      var counter:Number = 0;

       

      item1_mc.addEventListener(MouseEvent.MOUSE_DOWN,pickUp);
      item1_mc.addEventListener(MouseEvent.MOUSE_UP,dropIt);
      item2_mc.addEventListener(MouseEvent.MOUSE_DOWN,pickUp);
      item2_mc.addEventListener(MouseEvent.MOUSE_UP,dropIt);
      item3_mc.addEventListener(MouseEvent.MOUSE_DOWN,pickUp);
      item3_mc.addEventListener(MouseEvent.MOUSE_UP,dropIt);
      item4_mc.addEventListener(MouseEvent.MOUSE_DOWN,pickUp);
      item4_mc.addEventListener(MouseEvent.MOUSE_UP,dropIt);
      item5_mc.addEventListener(MouseEvent.MOUSE_DOWN,pickUp);
      item5_mc.addEventListener(MouseEvent.MOUSE_UP,dropIt);
      item6_mc.addEventListener(MouseEvent.MOUSE_DOWN,pickUp);
      item6_mc.addEventListener(MouseEvent.MOUSE_UP,dropIt);

       

      //

      //When item is picked up
      //

      function pickUp(event:MouseEvent):void {
          event.target.startDrag(true);
          reply_txt.text = "";
          event.target.parent.addChild(event.target);
          startX = event.target.x;
          startY = event.target.y;
      }

       

      //

      //When item is dropped

      //

      function dropIt(event:MouseEvent):void {
          event.target.stopDrag();
          var myTargetName:String = "target" + event.target.name;
          var myTarget:DisplayObject = getChildByName(myTargetName);
          if (event.target.dropTarget != null && event.target.dropTarget.parent == myTarget){
              reply_txt.text = "Good Job!";
              event.target.removeEventListener(MouseEvent.MOUSE_DOWN,pickUp);
              event.target.removeEventListener(MouseEvent.MOUSE_UP,dropIt);
              event.target.buttonMode = false;
              event.target.x = myTarget.x;
              event.target.y = myTarget.y;
              counter++;
          } else {
              reply_txt.text = "Try Again!";
              event.target.x = startX;
              event.target.y = startY;
          }
          if(counter == 6){
              reply_txt.text = "Congrats, you're finished!";

       

      //

      //This is added animation for movieclip 'Linkage' named "Congrats"
      //

      var congrats:Congrats = new Congrats();
      addChild(congrats);
      congrats.x = 394
      congrats.y = 269;
          }
      }

       

      //MovieClips are set to button mode
      item1_mc.buttonMode = true;
      item2_mc.buttonMode = true;
      item3_mc.buttonMode = true;
      item4_mc.buttonMode = true;
      item5_mc.buttonMode = true;
      item6_mc.buttonMode = true;