LoacalGlobal
/**
* Copyright fakestar0826 ( http://wonderfl.net/user/fakestar0826 )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/aqYd
*/
package {
import flash.geom.Vector3D;
import flash.geom.Point;
import flash.events.Event;
import flash.display.Sprite;
public class FlashTest extends Sprite
{
private var _sprite:Sprite;
private var _tracker:Sprite;
private var _angle:Number = 0;
public function FlashTest()
{
// write as3 code here..
_sprite = new Sprite();
_sprite.graphics.lineStyle(10);
_sprite.graphics.lineTo(200, 0);
_sprite.graphics.drawCircle(200, 0, 10);
_sprite.x = 200;
_sprite.y = 200;
addChild(_sprite);
_tracker = new Sprite();
_tracker.graphics.lineStyle(2, 0xFF0000);
_tracker.graphics.drawCircle(0, 0, 20);
addChild(_tracker);
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
private function onEnterFrame(e:Event):void
{
_sprite.rotationX +=1;
_sprite.rotationY += 1.2;
_sprite.rotationZ += 0.5;
_sprite.x = 200 + Math.cos(_angle) * 100;
_sprite.y = 200 + Math.sin(_angle) * 100;
_sprite.z = 100 + Math.cos(_angle + 0.8) * 400;
_angle += 0.05;
var p:Point = _sprite.local3DToGlobal(new Vector3D(200, 0, 0));
_tracker.x = p.x;
_tracker.y = p.y;
}
}
}