Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Sep 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help with action script 3.0 please

    Hey guys. I am trying to get my object (man) move and point to where the mouse is. It is comming up with errors:
    Scene 1, Layer 'actions', Frame 1, Line 1 1172: Definition flash.event:Event could not be found.
    and Scene 1, Layer 'actions', Frame 1, Line 1 1172: Definition flash.event:Event could not be found.
    Anyways, here is the code:
    import flash.event.Event;


    var man=new man();
    man.x=man.y=200;
    addChild(man);

    var ax:Number=0.3;
    var vx:Number=0;

    man.addEventListener(Event.ENTER_FRAME,onEnterFrame);

    function onEnterFrame(event:Event):void{
    var dx:Number=mouseX-man.x;
    var dy:Number=mouseY-man.y;
    var radians:Number=Math.atan2(dy,dx);
    man.rotation=radians*180/Math.PI;

    man.x=50;
    man.y=100;
    vx+=ax;
    man.x+=vx;
    }

    Any help would be greatly apriciated.

  • #2
    New Coder djpaul1963's Avatar
    Join Date
    Apr 2012
    Location
    Athens GR
    Posts
    74
    Thanks
    0
    Thanked 8 Times in 8 Posts
    3 errors here:

    replace import flash.event.Event;
    with import flash.events.Event;

    - just a typo

    replace var man=new man();
    with var man:Man = new Man(); // and change accordingly in properties of that class

    - class name must be different than its instance

    replace man.addEventListener(Event.ENTER_FRAME,onEnterFrame);
    with man.addEventListener(Event.ENTER_FRAME,onFrame);

    - onEnterFrame is a reserved word used for AS2 compatibility
    Everything can be done, but I don't know how.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •