リング3
/**
* Copyright freddy ( http://wonderfl.net/user/freddy )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/vbm2
*/
// forked from freddy's リング2
// forked from freddy's マッハの卵、比較
// forked from freddy's マッハの卵
package {
import flash.display.Shape;
import flash.events.Event;
import flash.display.Sprite;
public class FlashTest extends Sprite {
public function FlashTest() {
// write as3 code here..
function createEgg(ra0:Number, ra1:Number, rb0:Number, rb1:Number, x:int, y:int, rot:int, dx:Number, yy:Number = 0):Sprite {
var sp:Sprite = new Sprite();
var theta:Number;
var r:Number;
var f:Function;
sp.graphics.beginFill(0x000000);
for (var i:int = 0; i <= 360; i++) {
theta= i / 360 * 2 * Math.PI;
r = i / 360 * ra1 + ra0;
f = (i == 0 ? sp.graphics.moveTo : sp.graphics.lineTo);
f(r * Math.cos(theta) + dx, r * Math.sin(theta));
}
sp.graphics.endFill();
sp.graphics.beginFill(0xFFFFFF);
for (i = 0; i <= 360; i++) {
theta= (i - 15) / 360 * 2 * Math.PI;
r = i / 360 * rb1 + rb0;
f = (i == 0 ? sp.graphics.moveTo : sp.graphics.lineTo);
f(r * Math.cos(theta) + dx, r * Math.sin(theta));
}
sp.graphics.endFill();
sp.x = x;
sp.y = y;
var t:int;
sp.addEventListener(Event.ENTER_FRAME, function (e:Event):void {
sp.rotation += rot;
t++;
sp.y = y + yy * Math.sin(t * 8 / 360 * Math.PI * 2);
});
return sp;
}
function createEgg2(ra0:Number, ra1:Number, rb0:Number, rb1:Number, x:int, y:int, rot:int, yy:Number = 0):Sprite {
var sp:Sprite = new Sprite();
var theta:Number;
var r:Number;
var f:Function;
sp.graphics.beginFill(0x000000);
for (var j:int = 0; j < 2; j++) {
for (var i:int = 0; i <= 180; i++) {
theta= i / 360 * 2 * Math.PI + Math.PI * j;
r = i / 360 * ra1 + ra0;
f = (i == 0 ? sp.graphics.moveTo : sp.graphics.lineTo);
f(r * Math.cos(theta), r * Math.sin(theta));
}
}
for (var j:int = 0; j < 2; j++) {
for (var i:int = 0; i <= 180; i++) {
theta= (i - 15) / 360 * 2 * Math.PI + Math.PI * j;
r = i / 360 * rb1 + rb0;
f = (i == 0 ? sp.graphics.moveTo : sp.graphics.lineTo);
f(r * Math.cos(theta), r * Math.sin(theta));
}
}
sp.graphics.endFill();
sp.graphics.beginFill(0xFFFFFF);
sp.graphics.endFill();
sp.x = x;
sp.y = y;
var t:int;
sp.addEventListener(Event.ENTER_FRAME, function (e:Event):void {
sp.rotation += rot;
t++;
sp.y = y + yy * Math.sin(t * 8 / 360 * Math.PI * 2);
});
return sp;
}
this.addChild(createEgg2(100, 100, 65, 100, 800, 0, -20, 0));
this.addChild(createEgg(100, 50, 65, 60, 400, 0, -20, 0, 500));
this.addChild(createEgg(100, 50, 65, 60, 0, 0, 20, 0, 500));
this.addChild(createEgg(100, 50, 65, 60, -400, 0, 20, 0));
this.addChild(createEgg(100, 50, 65, 60, -800, 0, -20, 10, 500));
this.graphics.lineStyle(1, 0x0000FF);
scaleX = scaleY = 1/5;
x = 240;
y = 240;
}
}
}