A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Make Chracter move after the mouse (AS3)

  1. #1
    Registered User
    Join Date
    Oct 2015
    Posts
    1

    Unhappy Make Chracter move after the mouse (AS3)

    I don't know but with my simple logic shouldn't this be how i move the instance (Chare) after the mouse?
    This doesn't work show if you could tell me what i should do i what i shouldn't.
    P.S.
    Doesn't show any errors


    import flash.events.Event;
    import flash.events.MouseEvent;

    function update (evt:Event)
    {
    var moveY:Number = mouseY
    var moveX:Number = mouseX

    Chare.X = moveX
    Chare.Y = moveY
    }

  2. #2
    Junior Member
    Join Date
    Nov 2015
    Posts
    7
    If you're wanting to attach an image or movie clip then the only thing you should need in in this instance is:

    Chare.x = mouseX
    Chare.y = mouseY

    You shouldn't need to assign variables for them to get it to work, just specify that the instance is directly on the mouseX and mouseY values.

    For my own game, i also added line that says:

    Mouse.hide()

    to hide the mouse cursor so only the image was visible on the mouse pointer.

    Hope this helps

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