basic mouse drag
/**
* Copyright it_Hing ( http://wonderfl.net/user/it_Hing )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/g1di
*/
package {
import flash.events.MouseEvent;
import flash.display.Graphics;
import flash.display.Sprite;
public class FlashTest extends Sprite {
public function FlashTest() {
// write as3 code here..
var sprite:Sprite = new Sprite;
sprite.graphics.beginFill(0xff0000);
sprite.graphics.drawCircle(30, 30, 30);
sprite.graphics.endFill();
sprite.addEventListener( MouseEvent.MOUSE_DOWN, ooo);
sprite.addEventListener( MouseEvent.MOUSE_UP, ooo);
this.addChild( sprite );
}
private function ooo(event:MouseEvent):void
{
var sprite:Sprite = event.target as Sprite;
if ( event.type == MouseEvent.MOUSE_DOWN )
{
sprite.startDrag();
} else {
sprite.stopDrag();
}
}
}
}