drag the line
/**
* Copyright shapevent ( http://wonderfl.net/user/shapevent )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/bZNj
*/
package {
import flash.display.*;
import flash.events.*;
public class FlashTest extends Sprite {
public function FlashTest() {
var line:MovieClip = makeLine();
line.addEventListener(MouseEvent.MOUSE_DOWN, onDown);
stage.addEventListener(MouseEvent.MOUSE_UP, onUp);
}
private function onDown(e:MouseEvent):void{
e.currentTarget.startDrag();
}
private function onUp(e:MouseEvent):void{
stopDrag();
}
private function makeLine():MovieClip{
var line:MovieClip = new MovieClip();
line.graphics.lineStyle(0, 0);
line.graphics.lineTo(100, 100);
addChild(line);
var hitArea:MovieClip = new MovieClip();
hitArea.buttonMode = true;
hitArea.graphics.lineStyle(10,0x00FF00, 0.0); // change 0.0 to 0.5 to see what's going on
hitArea.graphics.lineTo(100, 100);
line.addChild(hitArea);
return line;
}
}
}