forked from: flash on 2012-3-19
forked from flash on 2012-3-19 (diff: 27)
ActionScript3 source code
/**
* Copyright MMMMMonchi ( http://wonderfl.net/user/MMMMMonchi )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/bDVH
*/
// forked from MMMMMonchi's flash on 2012-3-19
package {
import flash.display.Sprite;
import flash.events.Event;
import net.hires.debug.Stats;
[SWF(frameRate="60")]
public class Main extends Sprite {
public var bullets:Array;
private const MAX:int=400;
public function Main() {
addChild(new Stats());
bullets=new Array();
for(var degree:int = 0; degree < 360; degree+= 20){
bullets.push(new Ball(0x0, 30, 232, 232, Math.cos(degree * Math.PI / 180)*5, Math.sin(degree * Math.PI / 180)*5));
addChild(bullets[degree/20]);
}
addEventListener(Event.ENTER_FRAME,onEnterFrame);
}
public function onEnterFrame(e:Event):void{
for(var i:int=0;i<bullets.length;i++){
bullets[i].move();
if (bullets[i].check())
{
removeChild(bullets[i]);
bullets.splice(i--, 1);
}
}
}
}
}
import flash.geom.ColorTransform;
import flash.display.Sprite;
class Ball extends Sprite{
private var _x:Number = 0;
private var _y:Number = 0;
public var vx:Number;
public var vy:Number;
public var radius:int;
public var color2:ColorTransform;
override public function get x():Number { return _x; }
override public function get y():Number { return _y; }
override public function set x(value:Number):void
{
super.x = _x = value;
}
override public function set y(value:Number):void
{
super.y = _y = value;
}
public function Ball(color:uint,radius:int,x:int,y:int,vx:Number,vy:Number){
graphics.beginFill(color);
graphics.drawCircle(0,0,radius);
graphics.endFill();
this.x=x;
this.y=y;
this.vx=vx;
this.vy=vy;
this.radius=radius;
}
public function move():void{
//色を変える!!
color2=new ColorTransform();
color2.color=Math.random()*100000000;
this.x+=vx;
this.y+=vy;
if(this.x<radius||this.x>=stage.stageWidth-radius){vx=-vx; this.transform.colorTransform=color2;};
if(this.y<radius||this.y>=stage.stageHeight-radius){vy=-vy; this.transform.colorTransform=color2;};
}
public function check():Boolean
{
if (x < -50 || stage.stageWidth+10< x ||
y < -50 || stage.stageHeight+10< y)
{
return true;
}
return false;
}
}
