DrawSymmetric
20121124把一個問題解決了
/**
* Copyright junsucom ( http://wonderfl.net/user/junsucom )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/yD0F
*/
package {
import flash.text.TextField;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
public class FlashTest extends Sprite {
private var m_bIsDown:Boolean;
private var m_uX:Number;
private var m_uY:Number;
private var m_uCenX:uint;
private var m_uCenY:uint;
private var m_tfX:TextField;
private var m_tfY:TextField;
public function FlashTest() {
m_bIsDown = false;
this.parent.stage.addEventListener(MouseEvent.MOUSE_DOWN, doMouseDown);
this.parent.stage.addEventListener(MouseEvent.MOUSE_UP, doMouseUp);
this.parent.stage.addEventListener(Event.ENTER_FRAME, doEnterFrame);
graphics.lineStyle(1, 0);
/*
m_tfX=new TextField();
m_tfY=new TextField();
m_tfX.text="please press";
m_tfY.text="mouse buttom";
m_tfX.x=10;
m_tfX.y=10;
m_tfY.x=100;
m_tfY.y=10;
addChild(m_tfX);
addChild(m_tfY);
*/
}
private function doMouseDown(evt:MouseEvent):void
{
m_bIsDown = true;
m_uX = mouseX;
m_uY = mouseY;
m_uCenX = mouseX;
m_uCenY = mouseY;
}
private function doMouseUp(evt:MouseEvent):void
{
m_bIsDown = false;
}
private function doEnterFrame(evt:Event):void
{
if (m_bIsDown)
{
graphics.moveTo(m_uX , m_uY);
graphics.lineTo(mouseX, mouseY);
graphics.moveTo(2*m_uCenX-m_uX , 2*m_uCenY-m_uY);
graphics.lineTo(2*m_uCenX-mouseX , 2*m_uCenY-mouseY);
m_uX = mouseX;
m_uY = mouseY;
}
}
}
}