flash on 2010-4-13
/**
* Copyright zzz_x_zzz ( http://wonderfl.net/user/zzz_x_zzz )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/irrf
*/
package {
import flash.display.Sprite;
public class EventExample extends Sprite {
private const movieCount:int = 10;
private const rect:String = "rect";
private const circle:String = "circle";
private const line:String = "line";
private var movieTypeArr:Array ;
private var movieContainer:Array;
public function EventExample() {
movieTypeArr = [rect, circle, line];
movieContainer = [];
for ( var i:int = 0; i < movieCount; i++ ){
movieContainer[i] = new Square(int(Math.random() * 16777216)-1000, movieTypeArr[i % 3], this);
movieContainer[i].name = "mc_" + i ;
addChild(movieContainer[i]);
}
}
}
}
import flash.display.Sprite;
class Square extends Sprite {
private var color:Number;
private var squareType:String;
public var aroot:EventExample;
public function Square(color:Number, squareType:String, aroot:EventExample) {
this.color = color;
this.squareType = squareType;
this.aroot = aroot;
draw();
}
private function draw():void {
switch (squareType) {
case "rect" :
this.graphics.beginFill(color);
this.graphics.drawRect(Math.random()*300, Math.random()*300, Math.random()*200, Math.random()*200);
break;
case "circle" :
this.graphics.beginFill(color);
this.graphics.lineStyle(Math.random() * 10, color );
this.graphics.drawCircle(Math.random()*200, Math.random()*200, Math.random()*100);
this.graphics.endFill();
break;
case "line" :
this.graphics.lineStyle(Math.random() * 10, color );
this.graphics.moveTo(Math.random() * 300, Math.random() * 300);
this.graphics.lineTo(Math.random() * 300, Math.random() * 300);
break;
}
}
}