A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Drag with hitTestObject question

  1. #1
    Member
    Join Date
    Dec 2004
    Posts
    68

    Drag with hitTestObject question

    Is it possible while dragging a mc to have a conditional statement?

    What I would like to do is drag a mc and if it overlaps another mc, the dragging mc changes frame. It will only change frames when it is dropped, I would like to have it change frame while still dragging.

    Code:
    stop();
    function dragMe(e:MouseEvent):void {
    	dragObject.startDrag(true);
    	//does not have any effect
    	if (dragObject.hitTestObject(hitObject)) {
    		dragObject.gotoAndStop(2);
    	} else {
    		dragObject.gotoAndStop(1);
    	}
    }
    
    dragObject.addEventListener(MouseEvent.MOUSE_DOWN, dragMe);
    
    function dropMe(e:MouseEvent):void {
    	//but this works fine
    	if (dragObject.hitTestObject(hitObject)) {
    		dragObject.stopDrag();
    		dragObject.gotoAndStop(2);
    	} else {
    		dragObject.stopDrag();
    		dragObject.gotoAndStop(1);
    	}
    }
    dragObject.addEventListener(MouseEvent.MOUSE_UP, dropMe);

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    You need to have an ENTER_FRAME event or you can use a MOUSE_MOVE event.
    - The right of the People to create Flash movies shall not be infringed. -

  3. #3
    Member
    Join Date
    Dec 2004
    Posts
    68
    Thank You!

    Both work fine!

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