flash on 2011-3-2
昔書いたやつを見つけたので
//昔書いたやつを見つけたので
package {
import flash.display.Sprite;
import flash.events.*;
import flash.display.Shape;
import flash.display.GradientType;
import flash.geom.Matrix;
import flash.geom.ColorTransform;
[SWF(width = "465", height = "465", backgroundColor = 0xFFFFFF, frameRate = "60")]
public class RainbowRabbit extends Sprite{
private var container1:Sprite= new Sprite;
private var container2:Sprite= new Sprite;
private var container_rabi1:Sprite= new Sprite;
private var container_rabi2:Sprite= new Sprite;
private var mask1:Shape= new Shape();
private var mask2:Shape= new Shape();
public function RainbowRabbit(){
if (stage) init();else addEventListener(Event.ADDED_TO_STAGE,init );
}
private function init(ev:Event = null){
removeEventListener( Event.ADDED_TO_STAGE, init ) ;
addChild(container1);
addChild(container2);
var rot:Number = 2 * Math.PI * (90 / 360);
var gbm:Matrix = new Matrix();
gbm.createGradientBox(465, 465, rot, 0, 0);
mask1.graphics.beginGradientFill(GradientType.LINEAR, [0xFF3366, 0xFF66CC, 0x6633FF, 0x00CCFF, 0x99FF66, 0xFFCC33, 0xFF6633], [1, 1, 1, 1, 1, 1, 1], [0, 32,64,96,127,193, 225], gbm);
mask1.graphics.drawRect(0, 0, 465, 465);
mask2.graphics.beginGradientFill(GradientType.LINEAR, [0xFF66CC, 0x6633FF, 0x00CCFF, 0x99FF66, 0xFFCC33, 0xFFDD00, 0xFF3366], [1, 1, 1, 1, 1, 1, 1], [0, 32,64,96,161,193, 225], gbm);
mask2.graphics.drawRect(0, 0, 465, 465);
container1.addChild(mask1);
container2.addChild(mask2);
addChild(container_rabi1);
addChild(container_rabi2);
for (var j:uint=0; j < 128; j++) {
var mc:drawRabi=new drawRabi();
var mc2:drawRabi=new drawRabi();
mc.x=j % 8*60;
mc2.x=j % 8*60+30;
mc.y=mc2.y=Math.floor(j / 16)*60+30;
container_rabi1.addChild(mc);
container_rabi2.addChild(mc2);
}
main2();
}
private function main2(){
container1.cacheAsBitmap = container_rabi1.cacheAsBitmap =container2.cacheAsBitmap = container_rabi2.cacheAsBitmap =true;
container1.mask=container_rabi1;
container2.mask=container_rabi2;
}
//
}
}
import flash.display.MovieClip;
import flash.filters.GlowFilter;
class drawRabi extends MovieClip{
private var myArray0:Array=["_body","_head","_ear1","_ear2"];
private var myArray1:Array=[0,3,4,12];//_x
private var myArray2:Array=[0,-12,-20,-20];//_y
private var myArray3:Array=[20,15,5,5];//_width
private var myArray4:Array=[20,15,10,10];//_height
public function drawRabi( ){
var _pointX:uint=0;
var _pointY:uint=0;
var _array:Array=new Array();
for(var j:int=0; j < 4; j++)
{
var rb_sp:MovieClip = new MovieClip();
rb_sp.graphics.beginFill(0xffffff);
rb_sp.graphics.drawEllipse(0,0, myArray3[j], myArray4[j]);
//rb_sp.graphics.endFill();
if(j==1){
//rb_sp.graphics.beginFill(0xcc4d40);
rb_sp.graphics.drawCircle(4,5,1.2);
rb_sp.graphics.drawCircle(10,5,1.2);
rb_sp.graphics.drawCircle(7,9,1.7);
//rb_sp.graphics.endFill();
}
rb_sp.graphics.endFill(); //追加
filters = [ new GlowFilter( 0xffffff, 0.5, 50, 50, 4 ) ] ;
//しっかり入れとくこと
rb_sp.x=_pointX+myArray1[j];
rb_sp.y=_pointY+myArray2[j];
rb_sp.name=myArray0[j];
_array.push(rb_sp);
this.addChild(rb_sp);
}
}
}