dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: MOUSE_MOVE conflict

  1. #1
    Member
    Join Date
    Oct 2005
    Location
    Santa Barbara, California, USA
    Posts
    61

    MOUSE_MOVE conflict

    Once again I am trying to learn AS3. I made a movie where a compass points at the mouse position, and when the mouse rolls over a certain movie that movie plays the first part of an animation, and when the mouse rolls off of the movie the movie plays the second part of the animation.

    But, it doesn't work. If I delete the code that rotates the compass needle then the movies play fine.

    I imagine we have an internal process conflict with mouse position data, but I'm helpless to figure out how to solve the problem. (Well, the compass could tell the movies to play at certain degrees, but that is a way uphill pull for me).

    Here is the code:

    var dx:Number;
    var dy:Number;

    stage.addEventListener(MouseEvent.MOUSE_MOVE, stage_MOUSEMOVE);

    function stage_MOUSEMOVE(event:MouseEvent):void
    {
    point_to(compass_mc);
    }

    function point_to(mouse)
    {
    dx = mouseX - mouse.x;
    dy = mouseY - mouse.y;
    compass_mc.rotation = Math.atan2(dy, dx) * 180 / Math.PI;
    }



    knife_anim.addEventListener(MouseEvent.ROLL_OVER, knifeIn);
    knife_anim.addEventListener(MouseEvent.ROLL_OUT, knifeOut);

    function knifeIn(event:MouseEvent):void
    {
    knife_anim.gotoAndPlay(2);
    stage.removeEventListener(MouseEvent.MOUSE_MOVE, stage_MOUSEMOVE);
    }

    function knifeOut(event:MouseEvent):void
    {
    knife_anim.gotoAndPlay(18);
    }

  2. #2
    Member
    Join Date
    Oct 2005
    Location
    Santa Barbara, California, USA
    Posts
    61
    I just solved my problem. It's the weirdest darn thing. The compass that followed the mouse had a piece of art extending outwards like a ray. Whenever that would overlap the movies there would be a conflict. By putting the compass under the movies everything works fine now.

  3. #3
    Member
    Join Date
    Oct 2005
    Location
    Santa Barbara, California, USA
    Posts
    61
    And now this line from my buddy that solves the conflict:

    compass_mc.mouseEnabled = compass_mc.mouseChildren = false;

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