不建议用Sprite容器,最好用SpriteVisualElement(因为Sprite不能直接被Flex所接受,还要用UiComponent进行包装)(临时写的,请用FB4进行微调)
给Application注册MouseClick 事件, 大概代码:(用SpriteVisualElement举例)
private clickCount:uint = 0;
private startPoint:Point = null;
private function mouseClickHandler(event:MouseEvent):void{
clickCount++;
if(clickCount % 2 == 0){ //偶数
var line:SpriteVisualElement = new SpriteVisualElement();
var g:Graphics = line .graphics;
g.moveTo(startPoint.x, startPoint.y);
g.lineTo(event.localX, event.localY);
addElement(line);
}else{ //奇数
startPoint = new Point(event.localX, event.localY);
}
}