forked from: forked from: forked from: flash on 2010-1-13
forked from forked from: forked from: flash on 2010-1-13 (diff: 101)
ActionScript3 source code
/**
* Copyright Tamanegi_kenshi ( http://wonderfl.net/user/Tamanegi_kenshi )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/fwki
*/
package{
import flash.display.Sprite;
import flash.events.Event;
import flash.display.Sprite;
import flash.events.MouseEvent;
public class test extends Sprite{
private var ball:Ball;
private var ball1:Ball;
private var ballNum:int = 13;
private var balls:Array;
public function test(){
init()
}
private function init():void{
balls = new Array();
ball1 =new Ball(0x000000,200);
addChild(ball1);
ball1.x=ball1.y=230;
ball1.visible=false;
for(var k:int=0;k<ballNum;k++){
for(var i:int=0;i<ballNum;i++){
ball=new Ball(Math.random()*0xffffff,20);
ball.x +=i*40;
ball.y +=k*40;
addChild(ball);
balls.push(ball);
}
}
addEventListener(MouseEvent.CLICK,click);
}
private function click(event:MouseEvent):void{
addEventListener(Event.ENTER_FRAME,on);
}
private function on(event:Event):void{
for(var i:int=0;i<ballNum*ballNum;i++){
if(i%2 ==0){
balls[i].x +=5;
}else{
balls[i].x -=5;
}
if(balls[0].x>stage.stageWidth+30){
ball1.visible =true;
}
}
}
}
}
import flash.display.Sprite;
class Ball extends Sprite{
function Ball(color:uint,size:int){
this.graphics.beginFill(color);
this.graphics.drawCircle(0,0,size);
this.graphics.endFill();
}
}
