flash on 2010-1-12
とりあえず練習
package {
//とりあえず練習
import flash.display.Sprite;
import flash.display.MovieClip;
import flash.display.Shape;
import flash.events.*;
import flash.display.GradientType;
import flash.geom.Matrix;
[SWF(width = "465", height = "465", backgroundColor = 0x669900, frameRate = "60")]
public class rakugaki extends MovieClip {
private var bg:Sprite;
private var palette:Sprite;
private var canvas:Sprite;
private var lineColor:uint = 0x72AA00;
private var lineThickness:uint = 8;
private var mcNowSellect:MovieClip;
private var mc0:Sprite;
private var mc1:Sprite;
public function rakugaki() {init();}
private function init(){
//bg
bg=new Sprite();
var gradientBoxMatrix:Matrix = new Matrix();
gradientBoxMatrix.createGradientBox(465, 465, 0, 0, 0);
bg.graphics.beginGradientFill(GradientType.LINEAR, [0x72AA00,0xB9CE44,0x72AA00], [1,1,1], [0, 128, 255], gradientBoxMatrix);
bg.graphics.drawRect(0, 0, 465, 465);
bg.graphics.endFill();
//palette
palette=new Sprite();
palette.graphics.beginFill(0xffffff,1);
palette.graphics.drawRoundRect(430,30,15,60,8);
palette.graphics.drawRoundRect(430,115,15,50,15);
palette.graphics.drawCircle(428,106,8);
palette.graphics.drawCircle(446,100,8);
palette.graphics.endFill();
palette.graphics.lineStyle(4,0xffffff);
palette.graphics.moveTo( 428, 102 );
palette.graphics.lineTo( 437, 90 );
palette.graphics.moveTo( 444, 108 );
palette.graphics.lineTo( 437, 120 );
palette.graphics.endFill();
var bt5:paletteThickness=new paletteThickness(1.5);
bt5.x=437;bt5.y=125;
bt5.addEventListener(MouseEvent.MOUSE_UP, function(e){
lineThickness=1;
mcNowSellect.removeChild(mc0);
mc0=new paletteThickness(1.5);
mc0.x=446;mc0.y=100;
mcNowSellect.addChild(mc0);
});
palette.addChild(bt5);
var bt6:paletteThickness=new paletteThickness(3.8);
bt6.x=437.5;bt6.y=138;
bt6.addEventListener(MouseEvent.MOUSE_UP, function(e){
lineThickness=4;
mcNowSellect.removeChild(mc0);
mc0=new paletteThickness(3.8);
mc0.x=446;mc0.y=100;
mcNowSellect.addChild(mc0);
});
palette.addChild(bt6);
var bt7:paletteThickness=new paletteThickness(5);
bt7.x=437.5;bt7.y=155;
bt7.addEventListener(MouseEvent.MOUSE_UP, function(e){
lineThickness=8;
mcNowSellect.removeChild(mc0);
mc0=new paletteThickness(5);
mc0.x=446;mc0.y=100;
mcNowSellect.addChild(mc0);
});
palette.addChild(bt7);
var bt1:colorOrange=new colorOrange();
bt1.x=437;bt1.y=40;
bt1.addEventListener(MouseEvent.MOUSE_UP, function(e){
lineColor=0xFE7B00;
mcNowSellect.removeChild(mc1);
mc1=new colorOrange();
mc1.x=428;mc1.y=106;
mcNowSellect.addChild(mc1);
});
palette.addChild(bt1);
var bt2:colorGreen=new colorGreen();
bt2.x=437;bt2.y=53;
bt2.addEventListener(MouseEvent.MOUSE_UP, function(e){
lineColor=0x72AA00;
mcNowSellect.removeChild(mc1);
mc1=new colorGreen();
mc1.x=428;mc1.y=106;
mcNowSellect.addChild(mc1);
});
palette.addChild(bt2);
var bt3:colorLightGreen=new colorLightGreen();
bt3.x=437;bt3.y=66;
bt3.addEventListener(MouseEvent.MOUSE_UP, function(e){
mcNowSellect.removeChild(mc1);
mc1=new colorLightGreen();
mc1.x=428;mc1.y=106;
mcNowSellect.addChild(mc1);
lineColor=0x9DC12A;});
palette.addChild(bt3);
var bt4:colorWhite=new colorWhite();
bt4.x=437;bt4.y=80;
bt4.addEventListener(MouseEvent.MOUSE_UP, function(e){
mcNowSellect.removeChild(mc1);
mc1=new colorWhite();
mc1.x=428;mc1.y=106;
mcNowSellect.addChild(mc1);
lineColor=0xffffff;});
palette.addChild(bt4);
var btClear:drawFlower=new drawFlower();btClear.scaleX=btClear.scaleY=2;
btClear.x=437;btClear.y=18;
btClear.addEventListener(MouseEvent.MOUSE_UP, function(e){canvas.graphics.clear();});
palette.addChild(btClear);
addChildAt(bg,0);
addChildAt(palette,1);
////////////////////////////////////////////////////////////////////////////////////////////////////
mcNowSellect=new MovieClip();
addChild(mcNowSellect);
mc0=new paletteThickness(5);
mc0.x=446;mc0.y=100;
mcNowSellect.addChild(mc0);
mc1=new colorGreen();
mc1.x=428;mc1.y=106;
mcNowSellect.addChild(mc1);
////////////////////////////////////////////////////////////////////////////////////////////////////
bg.addEventListener( MouseEvent.MOUSE_DOWN, onCanvasMouseDownHandler );
bg.addEventListener( MouseEvent.MOUSE_UP, onCanvasMouseUpHandler );
canvas = new Sprite();
canvas.addEventListener( MouseEvent.MOUSE_DOWN, onCanvasMouseDownHandler );
canvas.addEventListener( MouseEvent.MOUSE_UP, onCanvasMouseUpHandler );
addChild( canvas );
}
function onCanvasMouseDownHandler( e:MouseEvent ):void {
canvas.graphics.lineStyle( lineThickness, lineColor, 1 );
canvas.graphics.moveTo( mouseX, mouseY );
canvas.addEventListener( Event.ENTER_FRAME, drawingHandler );
}
function onCanvasMouseUpHandler( e:MouseEvent ):void {
canvas.graphics.endFill();
canvas.removeEventListener( Event.ENTER_FRAME, drawingHandler );
}
function drawingHandler( e:Event ):void{canvas.graphics.lineTo( mouseX, mouseY );}
}
}
import flash.display.Sprite;
import flash.display.Shape;
import flash.display.GradientType;
import flash.geom.Matrix;
class paletteThickness extends Sprite{
public function paletteThickness(arg1:uint){
var array:Array=[1,4,8];
graphics.beginFill(0xffffff,1);
graphics.drawCircle(0,0,5);
graphics.beginFill(0xcdcdcd,1);
graphics.drawCircle(0,0,arg1);
}
}
class colorOrange extends Sprite{
public function colorOrange(){
var rot:Number = 2 * Math.PI * (90 / 360);
var sp:Sprite=new Sprite();
var gbm:Matrix = new Matrix();
gbm.createGradientBox(5, 5, rot, 0, -1);
sp.graphics.beginGradientFill(GradientType.LINEAR, [0xFFA03C, 0xFF7D00, 0xFF9933], [1, 1, 1], [0, 50, 225], gbm);
sp.graphics.drawCircle(0,0,5);
addChild(sp);
}
}
class colorGreen extends Sprite{
public function colorGreen(){
var rot:Number = 2 * Math.PI * (90 / 360);
var sp:Sprite=new Sprite();
var gbm:Matrix = new Matrix();
gbm.createGradientBox(5, 5, rot, 0, -1);
sp.graphics.beginGradientFill(GradientType.LINEAR, [0x94C516, 0x72AA00, 0xB9CE44], [1, 1, 1], [0, 50, 225], gbm);
sp.graphics.drawCircle(0,0,5);
addChild(sp);
}
}
class colorLightGreen extends Sprite{
public function colorLightGreen(){
var rot:Number = 2 * Math.PI * (90 / 360);
var sp:Sprite=new Sprite();
var gbm:Matrix = new Matrix();
gbm.createGradientBox(5, 5, rot, 0, -1);
sp.graphics.beginGradientFill(GradientType.LINEAR, [0xEAF2B1, 0xC3D825, 0xDEF246], [1, 1, 1], [0, 50, 225], gbm);
sp.graphics.drawCircle(0,0,5);
addChild(sp);
}
}
class colorWhite extends Sprite{
public function colorWhite(){
var sp:Sprite=new Sprite();
sp.graphics.lineStyle(1.25,0x72AA00,1);
sp.graphics.beginFill(0xffffff,1);
sp.graphics.drawCircle(0,0,5);
addChild(sp);
}
}
class drawFlower extends Sprite{
public function drawFlower(){
for(var j:int=0; j < 5; j++){
var fl_sp:Sprite = new Sprite();
fl_sp.graphics.beginFill(0xffffff);
fl_sp.graphics.drawEllipse(-1,0,2,5);
fl_sp.graphics.endFill();
fl_sp.rotation=j*72+180;
addChild(fl_sp);
}
}
}