Skip to main content
Participant
February 28, 2013
Question

as2 to as3 the class or interface 'MouseEvent' could not be loaded

  • February 28, 2013
  • 3 replies
  • 741 views

im using as2 but the scripts are supposed to be in as3

here's the code in as3:

for (var i:int=0; i<10; i++){

          var newFood:mcFood=new mcFood();

 

          newFood.buttonMode=true;

          newFood.x = (Math.random()*510);

          newFood.y = (Math.random()*310);

          if(newFood.x>550){

                    newFood.x -=530;

                    }

          if(newFood.y>550){

                    newFood.y -=530;

                    }

          addChild(newFood);

 

          newFood.addEventListener(MouseEvent.MOUSE_DOWN, mousePressed);

          newFood.addEventListener(MouseEvent.MOUSE_UP, mouseReleased);

}

function mousePressed(myVar:MouseEvent):void{

          myVar.target.startDrag();

          }

function mouseReleased(myVar:MouseEvent):void{

          myVar.target.stopDrag();

          if(myVar.target.hitTestObject(star)){

                    myVar.target.x = -300;

                    myVar.target.y = -30;

                    }

          }

could anyone transform this into as2?

This topic has been closed for replies.

3 replies

J_AngeloAuthor
Participant
March 1, 2013

I just want to implement the code as3 to the ninja thing, but i lack background in as2  sorry for bad english

J_AngeloAuthor
Participant
March 1, 2013

Basically Sir I do not have any background in using the as2. Since I started using the as3.

Hmm actually the code up there works fine, but when I add the character to the as3 and try to run it, it says that the the button will be ignored.

https://www.dropbox.com/s/l88ztx7o9qipbbw/asasasa.fla

Ned Murphy
Legend
March 1, 2013

Then don't use AS2.  Use AS3.

Ned Murphy
Legend
February 28, 2013

You should take a shot at it first and then post what you end up with.