prog.hu: AS3 class MouseEvent error teszt
http://prog.hu/tudastar/121124-10/AS3+class+MouseEvent+error.html
♥0 |
Line 28 |
Modified 2010-08-07 22:57:21 |
MIT License
archived:2017-03-20 13:14:46
ActionScript3 source code
/**
* Copyright szbzs2004 ( http://wonderfl.net/user/szbzs2004 )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/i55R
*/
// http://prog.hu/tudastar/121124-10/AS3+class+MouseEvent+error.html
package {
import flash.display.MovieClip;
import flash.events.MouseEvent;
public class Ellipse extends MovieClip{
private var eHeight:uint;
private var eWidth:uint;
private var eColor:uint;
public function Ellipse(h:uint=40,w:uint=40,c:uint=0xff0000) {
eHeight = h;
eWidth = w;
eColor = c;
stage.addEventListener(MouseEvent.MOUSE_DOWN, startPainting);
stage.addEventListener(MouseEvent.MOUSE_UP, stopPainting);
}
private function startPainting(e:MouseEvent):void {
stage.addEventListener(MouseEvent.MOUSE_MOVE, doPainting);
eColor = Math.random()*0xFFFFFF;
}
private function stopPainting(e:MouseEvent):void {
stage.removeEventListener(MouseEvent.MOUSE_MOVE, doPainting);
}
private function doPainting(e:MouseEvent):void {
graphics.beginFill(eColor);
graphics.drawEllipse(mouseX-(eWidth/2), mouseY-(eHeight/2), eWidth, eHeight);
graphics.endFill();
}
}
}