flash on 2009-6-24
♥0 |
Line 90 |
Modified 2009-06-24 19:17:53 |
MIT License
archived:2017-03-20 04:59:22
ActionScript3 source code
/**
* Copyright set0 ( http://wonderfl.net/user/set0 )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/oxrM
*/
package
{
import flash.display.*;
import flash.events.*;
[SWF(width=465, height=465, frameRate=60, backgroundColor=0x000000)]
public class FlashTest3d01 extends Sprite
{
private var sp_list:Array = [];
private var flag:int = 0;
public function FlashTest3d01()
{
Wonderfl.capture_delay(10);
var center_x:Number = stage.stageWidth / 2;
var center_y:Number = stage.stageHeight / 2;
var max:int = 500;
for (var i:int = 0; i < max; i++) {
sp_list[i] = new Plus(center_x, center_y, (max - i) * 10 + 3000, i % 2);
addChild(sp_list[i]);
}
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
private function onEnterFrame(e:Event):void
{
var max:int = sp_list.length;
if(flag == 0) {
for (var i:int = 0; i < max; i++) {
if (sp_list[i].move(stage.mouseX, stage.mouseY) == false) {
flag = 1;
}
}
} else {
for (i = 0; i < max; i++) {
sp_list[i].moveMouse(stage.mouseX, stage.mouseY);
}
}
}
}
}
import flash.display.*;
class Plus extends Sprite
{
public var _z:Number = 1000;
public var init_x:Number;
public var init_y:Number;
public var center_x:Number;
public var center_y:Number;
public var fl:Number = 100;
public var flag:int = 0;
public function Plus(x:Number, y:Number, z:Number, flag:int)
{
this.x = -100;
this.y = -100;
this.init_x = -100;
this.init_y = -100;
this.center_x = x;
this.center_y = y;
this._z = z;
this.flag = flag;
var color:uint = 0x0099ff;
if (flag == 0) {
color = 0xff9900;
}
graphics.lineStyle(8, color, 1, false, "normal", CapsStyle.SQUARE);
graphics.moveTo(10, 0);
graphics.lineTo(10, 20);
graphics.moveTo(0, 10);
graphics.lineTo(20, 10);
}
public function move(x:Number, y:Number):Boolean
{
this._z -= 10;
if (this._z < 0 ) {
return false;
}
moveMouse(x, y);
return true;
}
public function moveMouse(x:Number, y:Number):void
{
var scale:Number = this.fl / (this.fl + this._z);
this.init_x = Math.cos((this._z + 180 * flag) * Math.PI / 180) * 400;
this.init_y = Math.sin((this._z + 180 * flag) * Math.PI / 180) * 400;
this.init_x += (this.center_x - x) * 5;
this.init_y += (this.center_y - y) * 5;
this.x = this.init_x * scale + this.center_x;
this.y = this.init_y * scale + this.center_y;
this.scaleX = scale;
this.scaleY = scale;
}
}