クラス定義の練習 其の参
大重美幸[著]詳細ActionScript3.0の練習
/**
* Copyright argon ( http://wonderfl.net/user/argon )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/iEyX
*/
package
{
import flash.display.Sprite;
import flash.events.Event;
/**
* ...
* @author I am Afro Boy ヾ(。`Д´。)ノ
*/
public class Main extends Sprite
{
private var sp:FuncRotate;
public function Main():void
{
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
// entry point
for (var i:int = 0; i < 50; i++)
{
sp = new FuncRotate(10, 30);
sp.x = stage.stageWidth * Math.random();
sp.y = stage.stageHeight * Math.random();
addChild(sp);
sp.scaleX = sp.scaleY = 1 + Math.random() * 2;
}
}
}
}
import flash.display.Sprite;
import flash.events.Event;
/**
* ...
* @author I am Afro Boy ヾ(。`Д´。)ノ
*/
class AddRect extends Sprite
{
public function AddRect()
{
graphics.beginFill(Math.random() * 0xffffff);
graphics.drawRect(0, 0, 5 + Math.random() * 7, 5 + Math.random() * 7);
graphics.endFill();
addEventListener(Event.ENTER_FRAME, onEnterFrameHandler);
}
private function onEnterFrameHandler(e:Event):void
{
rotation += .5;
}
}
import flash.display.Sprite;
import flash.events.Event;
import flash.geom.Point;
/**
* ...
* @author I am Afro Boy ヾ(。`Д´。)ノ
*/
class FuncRotate extends Sprite
{
private var rotateSP:AddRect;
function FuncRotate(num:uint, leng:uint )
{
var rad:Number = 2 * Math.PI / num;
for (var i:int = 0; i < num; i++)
{
rotateSP = new AddRect();
var pt:Point = Point.polar(leng, num*i);
rotateSP.x = pt.x;
rotateSP.y = pt.y;
addChild(rotateSP);
}
}
}