forked from: forked from: 親オブジェクト自体の回転
appendRotationを使った親オブジェクト自体の回転
/**
* Copyright challengeyh ( http://wonderfl.net/user/challengeyh )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/fuoS
*/
// forked from code's 親オブジェクト自体の回転
package
{
/*
*appendRotationを使った親オブジェクト自体の回転
*
*/
import flash.display.*;
import flash.events.*;
import flash.geom.*;
public class setSpherePosition2 extends Sprite
{
//プロパティ
private var paBase:Sprite;
private var base:Sprite;
private const RADIUS:uint = 200;
private var itemNumber:uint;
private var planeWidth:uint = 20;
private var planeHeight:uint = 20;
private const imgMargin:uint = 80;
private var imgWidth:uint = planeWidth + imgMargin;
private var imgHeight:uint = planeHeight + imgMargin;
private var isMouseOut:Boolean = true;
private var axisAngle:Number = Math.PI * 2 / 3;
private var myAngle:Number = Math.PI;
//コンストラクタ
public function setSpherePosition2()
{
//プロファイラ
//SWFProfiler.init(stage, this);
//画像の初期配置
setPosition();
private function setPosition():void
{
var unitY:int = (RADIUS * 2 * Math.PI) / 2 / imgHeight;
var angleAlpha:Number;
var angleBeta:Number=Math.PI/2;
itemNumber = 0;
for (var i:uint = 0; i < unitY; i++)
{
angleAlpha = 0;
//円周上に配置できる画像数を計算
var alphaSets:int=Math.floor((2 * RADIUS * Math.cos(angleBeta) * Math.PI) / imgWidth);
for (var j:uint = 0; j < alphaSets; j++)
{
var plane:Sprite = new Sprite();
plane.graphics.clear();
plane.graphics.beginFill(0xffffff*Math.random(), 1);
plane.graphics.drawRect( -imgWidth / 2+imgMargin/2, -imgHeight / 2+imgMargin/2, planeWidth,planeHeight);
plane.graphics.endFill();
plane.rotationX = -angleBeta/Math.PI/2*360;
plane.rotationY = angleAlpha/Math.PI/2*360;
plane.x = RADIUS * Math.cos(angleBeta) * Math.sin(angleAlpha);
plane.y=RADIUS * Math.sin(angleBeta);
plane.z=RADIUS * Math.cos(angleBeta) * Math.cos(angleAlpha);
angleAlpha += Math.PI * 2 / alphaSets;
plane.name = "plane" + itemNumber.toString();
base.addChild(plane);
itemNumber++;
}
angleBeta -= Math.PI / unitY;
}
}
}
}