Quantumwave Interactive Inc.
  Interactive media development . Programming . Design . Consulting

Using _droptarget to detect the top-most movieclip in Flash 5

Mouse events in Flash apply to all movieclips. For example, when a mouseDown event is fired, all movieclips receive this event. One way to determine if a particular movieclip has been clicked is by using hitTest(). However, when movieclips are overlapped, hitTest() returns 'true' for all movieclips under the mouse cursor; therefore, it is difficult to manipulate the top-most movieclip using this method.

To demonstrate, try dragging a rectangle on top of the copyright text and let go. If the mouse is over the text, the mouseUp event will trigger the getURL() method; this is usually undesirable.

Instead of using hitTest(), we can also use _droptarget to achieve onPress, onRelease, onRollOver and onRollOut events for each rectangular "button". Each rectangle moves to the front when clicked or dragged, and returns to the original depth when released.

Another feature of this demo is when a rectangle is double-clicked, it is moved to the front. This is a done by using a property of the DemoButtonClass to implement the DoubleClickable class.

This demonstration also showcases the use of FLEM, and part of DAVE with virtual movieclip class, and DoubleClickable class. It does not account for using startDrag() and stopDrag() for dragging other movieclips; the dragging of rectangles is done with custom code.

Download source files: dropClip.zip

Last updated on: Feb 12, 2002 - Copyright © 2002 Dave Yang / Quantumwave Interactive Inc.

home | about | news | flash | director | shockwave | download | dave | résumé | contact

Copyright © 1995-2009 Quantumwave Interactive Inc.