flash on 2011-2-28
package {
import flash.display.Sprite;
import flash.events.*;
import flash.text.*;
[SWF(width = "465", height = "465", backgroundColor = 0x83A817, frameRate = "60")]
public class Pyramid extends Sprite{
private var myArray:Array=new Array();
private var marginX:uint;
private static const marginY:uint=50;
private static const space:uint=60;
private var delimit:uint;
private var tf:TextField = new TextField();
public function Pyramid(){
if (stage) init();else addEventListener(Event.ADDED_TO_STAGE,init );
}
public function init(ev:Event = null){
var bg:back_ground=new back_ground();
addChildAt(bg,0);
removeEventListener( Event.ADDED_TO_STAGE, init ) ;
tf.type=TextFieldType.INPUT;
tf.border=tf.background=true;
tf.restrict = "0-9";
tf.maxChars = 3;
tf.width=50;
tf.height=20;
tf.x=380;
tf.y=25;
tf.text="10";
addChild(tf);
var bt:bt1=new bt1();
bt.x=450;
bt.y=35;
bt.buttonMode = true;
addChild(bt);
bt.addEventListener(MouseEvent.MOUSE_DOWN, clicks);
}
private function clicks(ev){
if(myArray.length>0){reset();}
myArray=[];
var max:uint=Number(tf.text);
var cnt:uint=1;
marginX=0;
delimit=1;
for(var q:int=0; q < max; q++){
marginX=232-Math.floor(60*(delimit-1)/2);
var mc:drawChick=new drawChick;
var yoko:uint= cnt % delimit;
mc.x= yoko*space+marginX;
mc.y= delimit*space+marginY;
myArray.push(mc);
addChild(mc);
if(cnt==delimit){cnt=1;delimit++;}else{cnt++;}
}
}
private function reset(){
for(var qq:int=0; qq < myArray.length; qq++){
var mcq=myArray[qq]
removeChild(mcq);
mcq=null;
}
}
}
}
import flash.display.Sprite;
import flash.filters.GlowFilter;
class drawChick extends Sprite{
private var head:Sprite=new Sprite();
private var body:Sprite=new Sprite();
private var scarf:Sprite=new Sprite();
public var foot:Sprite=new Sprite();
/*public var dire:uint=Math.floor(Math.random()*2);
public var angel:uint=1;*/
public function drawChick(){
head.graphics.beginFill(0xFFCC33);
head.graphics.drawCircle(0,0,10);//head
head.graphics.endFill();
var head_1:Sprite = new Sprite();
head_1.graphics.beginFill(0x34929A);//eye
head_1.graphics.drawCircle(-1,-1,2);
head_1.graphics.endFill();
head_1.graphics.beginFill(0xF6712E);//Bill
head_1.graphics.drawEllipse(-15,-2,7,4);
head_1.graphics.endFill();
head.addChild(head_1);
addChild(head);
body.graphics.beginFill(0xFFCC33);//body
body.graphics.drawEllipse(2,2,30,20);
body.graphics.endFill();
var body_1:Sprite = new Sprite();
body_1.graphics.beginFill(0xFFCC33);//teil
body_1.graphics.moveTo(20,5);
body_1.graphics.lineTo(35,-1);
body_1.graphics.lineTo(32,13);
body_1.graphics.endFill();
body.addChild(body_1);
addChild(body);
foot.graphics.lineStyle(2,0xF6721E);//foot
foot.graphics.moveTo(18,23);
foot.graphics.lineTo(18,25);
foot.graphics.moveTo(18,25);
foot.graphics.lineTo(15,30);
foot.graphics.moveTo(18,25);
foot.graphics.lineTo(12,28);
foot.graphics.moveTo(18,25);
foot.graphics.lineTo(10,25);
foot.graphics.endFill();
addChild(foot);
scarf.graphics.beginFill(0xEF324E);
scarf.graphics.drawEllipse(-5,8,14,3);
scarf.graphics.endFill();
scarf.rotation=-40;
var scarf_1:Sprite = new Sprite();
scarf_1.graphics.beginFill(0xEF324E);
scarf_1.graphics.drawEllipse(0,0,15,5);
scarf_1.graphics.endFill();
scarf_1.rotation=-60;
scarf_1.x=5;scarf_1.y=8;
var scarf_2:Sprite = new Sprite();
scarf_2.graphics.beginFill(0xEF324E);
scarf_2.graphics.drawEllipse(0,0,15,5);
scarf_2.graphics.endFill();
scarf_2.rotation=-20;
scarf_2.x=5;scarf_2.y=8;
scarf.addChild(scarf_2);
scarf.addChild(scarf_1);
addChild(scarf);
}
}
class bt1 extends Sprite{
public function bt1( ){
this.graphics.beginFill(0xFFCC33);
this.graphics.drawCircle(0,0,10);
this.graphics.endFill();
this.graphics.beginFill(0x34929A);//eye
this.graphics.drawCircle(-3.5,-2,1.5);
this.graphics.drawCircle(3.5,-2,1.5);
this.graphics.endFill();
this.graphics.beginFill(0xF6712E);//Bill
this.graphics.drawEllipse(-4,1,8,4);
this.graphics.endFill();
}
}
class back_ground extends Sprite{
public function back_ground(){
var bg:Sprite=new Sprite();
bg.graphics.beginFill(0x83A817,1);
bg.graphics.drawRect(0,0,465,465);
bg.graphics.endFill();
for(var j:int=0; j < 625; j++){
var dot:Sprite=new Sprite();
dot.graphics.beginFill(0xdbdb00,0.1);
dot.graphics.drawRect(0,0,25,25);
dot.graphics.endFill();
dot.y=Math.floor(j / 25)*25;
if(j%2==0){dot.x=j%25*25-25;}else{dot.x=j%25*25;}
bg.addChild(dot);
}
addChild(bg);
}
}