글
flex와 actionscript
언어/ActionScript 3.0
2008/10/18 19:35
초 간단한 마우스로 선그리기 예제.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="test()">
<mx:Script>
<![CDATA[
public function test():void
{
can.addEventListener(MouseEvent.MOUSE_DOWN, mouseDHandler);
can.addEventListener(MouseEvent.MOUSE_UP, mouseUHandler);
can.addEventListener(MouseEvent.MOUSE_MOVE, mouseMHandler);
}
private function mouseDHandler(ent:Event):void
{
can.graphics.lineStyle(5, 1, 1, true);
can.graphics.moveTo(can.mouseX, can.mouseY);
can.addEventListener(MouseEvent.MOUSE_MOVE, mouseMHandler);
}
private function mouseUHandler(ent:Event):void
{
can.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMHandler);
}
private function mouseMHandler(ent:Event):void
{
draw(can.mouseX, can.mouseY);
}
private function draw(x:int, y:int):void
{
can.graphics.lineTo(x, y);
}
]]>
</mx:Script>
<mx:Panel id="pnl" x="10" y="10" width="398" height="369" layout="absolute">
<mx:Canvas x="0" y="0" width="378" height="329" id="can">
</mx:Canvas>
</mx:Panel>
</mx:Application>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="test()">
<mx:Script>
<![CDATA[
public function test():void
{
can.addEventListener(MouseEvent.MOUSE_DOWN, mouseDHandler);
can.addEventListener(MouseEvent.MOUSE_UP, mouseUHandler);
can.addEventListener(MouseEvent.MOUSE_MOVE, mouseMHandler);
}
private function mouseDHandler(ent:Event):void
{
can.graphics.lineStyle(5, 1, 1, true);
can.graphics.moveTo(can.mouseX, can.mouseY);
can.addEventListener(MouseEvent.MOUSE_MOVE, mouseMHandler);
}
private function mouseUHandler(ent:Event):void
{
can.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMHandler);
}
private function mouseMHandler(ent:Event):void
{
draw(can.mouseX, can.mouseY);
}
private function draw(x:int, y:int):void
{
can.graphics.lineTo(x, y);
}
]]>
</mx:Script>
<mx:Panel id="pnl" x="10" y="10" width="398" height="369" layout="absolute">
<mx:Canvas x="0" y="0" width="378" height="329" id="can">
</mx:Canvas>
</mx:Panel>
</mx:Application>
"와서 이미지 에디터 개발해볼래요?" 한마디에 " 네!!!!!!!! " 하고 달려온 회사.
(아.. 오가는 대화는 더 많았다는 ㅡ0ㅡ)
flex개발을 하기 위해 2주동안 안돌아가는 머리로 힘들었습니다..
도대체가 이건 어떻게 되는건지 이해가 안되서, 저렇게 간단한 선 그리기 예제를,
이제서야 술술 코딩하게 되었습니다. 아직 많은게 부족하지만,
TNC에서 개발해보고싶었던 이미지 에디터, 그림판 같은 프로그램들의 개발을 열심히 해봐야겠어용..
왜냐하면.. 전 소중하니까요. ㅋ ㅑ~ ㅋㅋㅋ
새로운걸 배우는건 재미있고 신나네용.. 열심히 해야겠어요 잇힝~♡