flash on 2010-5-10
♥0 |
Line 33 |
Modified 2010-05-10 18:13:30 |
MIT License
archived:2017-03-20 16:34:57
ActionScript3 source code
/**
* Copyright saku_K ( http://wonderfl.net/user/saku_K )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/eF6P
*/
package {
import flash.display.Sprite;
import flash.display.StageQuality;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.events.KeyboardEvent;
import flash.ui.Mouse;
import flash.ui.Keyboard;
public class FlashTest extends Sprite {
public function FlashTest() {
var isFirst:Boolean = true;
var color:uint = 0xff0000;
stage.addEventListener(MouseEvent.CLICK,drawLine);
stage.addEventListener(KeyboardEvent.KEY_DOWN,clearLine);
graphics.lineStyle(4,color);
function drawLine(event:MouseEvent):void {
if(isFirst){
graphics.moveTo(event.localX,event.localY);
isFirst = !isFirst;
} else {
graphics.lineTo(event.localX,event.localY);
}
}
function clearLine(event:KeyboardEvent):void {
if (event.keyCode == Keyboard.SPACE){
graphics.clear();
isFirst = true;
graphics.lineStyle(4,color);
}
}
// write as3 code here..
}
}
}