A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Moving Hero With Mouse

  1. #1
    Senior Member
    Join Date
    Jan 2008
    Posts
    107

    Moving Hero With Mouse

    Hello. I want to do a game where you control your main character with the mouse. But I kinda forget the code needed to achieve that.

    Isn't something like:

    Code:
    hero.x = MouseX;
    hero.y = MouseY;
    I tried several variatons but it doesn't work.

    I´m using Flash CS3 and Actionscript 3.0 by the way.

  2. #2
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    You're close. mouseX, mouseY with a lower-case m. If you just use it unqualified, it will be the coordinates relative to the root or whatever DisplayObject that code is in. You can use stage.mouseX, stage.mouseY to use global coordinates.

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center