A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Press and hover detection

  1. #1
    Junior Member
    Join Date
    Jan 2014
    Posts
    12

    Press and hover detection

    I want to detect when the mouse is pressed & held and hovered over a certain movieclip, let's call it "a"

    How can I detect this action ?

  2. #2
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    971
    import flash.events.MouseEvent;

    var hold:Boolean;

    stage.addEventListener(MouseEvent.MOUSE_MOVE, Controls);
    stage.addEventListener(MouseEvent.MOUSE_DOWN, Controls);
    stage.addEventListener(MouseEvent.MOUSE_UP, Controls);
    function Controls(e:MouseEvent):void
    {
    switch(e.type)
    {
    case "mouseMove":
    if(hold == true)
    {
    trace("hold = true");
    if(a.hitTestPoint(mouseX, mouseY))
    {
    trace('is touching "a"');
    }
    }
    break;

    case "mouseDown":
    hold = true;
    break;

    case "mouseUp":
    hold = false;
    break;
    }
    }
    Already mastering AS3. It was so fun. Now into Javascript and PHP and all its libraries

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