「サインコサイン(4)」からさらに発展させて、点を8つにしてみた。
【製作過程】
基本的には「サインコサイン(4)」と同じ。
ただ、MC「ball」のサイズを目立たないように2x2にしている。
以下、コード。
//中心点
var center:Number=150;
//中心からの距離(Y軸)
var away:Number=50;
//半径
var radius:Number=100;
//初期角度
var angle0:Number=0;
var angle1:Number=90;
var angle2:Number=180;
var angle3:Number=270;
//「ball」インスタンス生成
for(var i:Number=0;i<8;i++){
newname="ball"+i;
_root.attachMovie("ball",newname,i);
}
//loop関数定義
function loop():Void{
clear();
angle0+=4;
angle1+=4;
angle2+=4;
angle3+=4;
var radian0:Number=Math.PI/180*angle0;
var radian1:Number=Math.PI/180*angle1;
var radian2:Number=Math.PI/180*angle2;
var radian3:Number=Math.PI/180*angle3;
//上方4点配置
_root["ball0"]._x=Math.cos(radian0)*radius+center;
_root["ball0"]._y=Math.sin(radian0)*radius/5+center-away;
_root["ball1"]._x=Math.cos(radian1)*radius+center;
_root["ball1"]._y=Math.sin(radian1)*radius/5+center-away;
_root["ball2"]._x=Math.cos(radian2)*radius+center;
_root["ball2"]._y=Math.sin(radian2)*radius/5+center-away;
_root["ball3"]._x=Math.cos(radian3)*radius+center;
_root["ball3"]._y=Math.sin(radian3)*radius/5+center-away;
//線の描画
_root.lineStyle(1,0xFFFFFF);
_root.moveTo(_root["ball0"]._x,_root["ball0"]._y);
_root.lineTo(_root["ball1"]._x,_root["ball1"]._y);
_root.lineTo(_root["ball2"]._x,_root["ball2"]._y);
_root.lineTo(_root["ball3"]._x,_root["ball3"]._y);
_root.lineTo(_root["ball0"]._x,_root["ball0"]._y);
//下方4点配置
_root["ball4"]._x=Math.cos(radian0)*radius+center;
_root["ball4"]._y=Math.sin(radian0)*radius/5+center+away;
_root["ball5"]._x=Math.cos(radian1)*radius+center;
_root["ball5"]._y=Math.sin(radian1)*radius/5+center+away;
_root["ball6"]._x=Math.cos(radian2)*radius+center;
_root["ball6"]._y=Math.sin(radian2)*radius/5+center+away;
_root["ball7"]._x=Math.cos(radian3)*radius+center;
_root["ball7"]._y=Math.sin(radian3)*radius/5+center+away;
//線の描画
_root.moveTo(_root["ball4"]._x,_root["ball4"]._y);
_root.lineTo(_root["ball5"]._x,_root["ball5"]._y);
_root.lineTo(_root["ball6"]._x,_root["ball6"]._y);
_root.lineTo(_root["ball7"]._x,_root["ball7"]._y);
_root.lineTo(_root["ball4"]._x,_root["ball4"]._y);
//縦線の描画
_root.moveTo(_root["ball0"]._x,_root["ball0"]._y);
_root.lineTo(_root["ball4"]._x,_root["ball4"]._y);
_root.moveTo(_root["ball1"]._x,_root["ball1"]._y);
_root.lineTo(_root["ball5"]._x,_root["ball5"]._y);
_root.moveTo(_root["ball2"]._x,_root["ball2"]._y);
_root.lineTo(_root["ball6"]._x,_root["ball6"]._y);
_root.moveTo(_root["ball3"]._x,_root["ball3"]._y);
_root.lineTo(_root["ball7"]._x,_root["ball7"]._y);
}
setInterval(loop,33);

コメントする