dcsimg
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: mouse move detection

  1. #1
    Junior Member
    Join Date
    Apr 2008
    Posts
    17

    mouse move detection

    Hi,

    I need to detect vertical and horizontal move of the mouse pointer to drag
    vertical or horizontal group of objects but I don't know how to define the if statement

    PHP Code:
    b1_mc.buttonMode true;
    var 
    draggingFlag:Boolean false;


    b1_mc.addEventListener(MouseEvent.MOUSE_UPstopDragging);
    function 
    stopDragging(event:MouseEvent):void
    {
        
    draggingFlag false;
        
    event.target.stopDrag();
    }

    b1_mc.addEventListener(MouseEvent.MOUSE_DOWNczyMoznaPrzeciagac);
    function 
    czyMoznaPrzeciagac(event:MouseEvent):void
    {
        
    draggingFlag true;
    }

    b1_mc.addEventListener(MouseEvent.MOUSE_MOVEstartDragging);
    function 
    startDragging(event:MouseEvent):void
    {
        if (
    draggingFlag)
        {
            
    trace("horizontal");
            
    event.target.startDrag(false, new Rectangle(0,0,stage.width,1));
        }
        else if (
    draggingFlag)
        {
            
    trace("vertical");
            
    event.target.startDrag(false, new Rectangle(0,0,1,stage.height));
        }



    http://rapidshare.com/files/210035384/kwadrat.fla.html
    this is my .fla file I would like to drag this blue square horizontaly or vertically it depens on our mouse pointer

    regards

  2. #2
    Senior Member jweeks123's Avatar
    Join Date
    Mar 2006
    Posts
    1,124
    Not quite sure what you've got going on here, but if you want to find the mouse position everytime the mouse moves you'd need something like this:

    Code:
    addEventListener(MouseEvent.MOUSE_MOVE, checkPos);
    function checkPos(evt:MouseEvent):void {
    trace(mouseX);
    trace(mouseY);
    }

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