topical media & game development
animation-ch07-Drag.ax
animation-ch07-Drag.ax
[swf]
[flash]
flex
package
{
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.geom.Rectangle;
public class @ax-animation-ch07-Drag extends Sprite
{
private var ball:animation_ch07_Ball;
public function @ax-animation-ch07-Drag()
{
init();
}
private function init():void
{
ball = new animation_ch07_Ball();
ball.x = 100;
ball.y = 100;
addChild(ball);
ball.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
}
private function onMouseDown(event:MouseEvent):void
{
stage.addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
ball.startDrag(false, new Rectangle(100, 100, 300, 300));
}
private function onMouseUp(event:MouseEvent):void
{
stage.removeEventListener(MouseEvent.MOUSE_UP, onMouseUp);
ball.stopDrag();
}
}
}
(C) Æliens
04/09/2009
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.