First post... just testing different possibilities like embedding swf files and the Syntax Highlighter for ActionScript.
Actionscript:
/**
* @class: Plot3d
* @author: Luis Martinez luis@lessrain.com
* @version: 1.0
*
*/
class Plot3d {
private var _targetMC:MovieClip;
private var _centreX:Number;
private var _centreY:Number;
private var _direction:Number;
private var _theta:Number;
private var _radius:Number;
public static var FOCAL_LENGTH:Number = 230;
function Plot3d(clip:MovieClip) {
_targetMC = clip;
}
public function init(centreX:Number,centreY:Number, radius:Number, dir:Number):Void {
_centreX = centreX;
_centreY = centreY;
_direction = dir;
_radius = radius;
_targetMC._y = _centreY;
}
public function updatePosition():Void {
_theta *= _direction;
var x:Number = Math.cos(_theta*(Math.PI/-180))*_radius;
var z:Number = Math.sin(_theta*(Math.PI/-180))*_radius;
var scaleRatio:Number = FOCAL_LENGTH/(FOCAL_LENGTH+z);
_targetMC._x = Math.floor(_centreX+(x*scaleRatio));
_targetMC._xscale = _targetMC._yscale=Math.floor(100*scaleRatio);
_targetMC.swapDepths(Math.round(-z));
}
public function set theta(t:Number):Void {
_theta = t;
}
public function get theta():Number {
return _theta;
}
public function getTarget():MovieClip {
return _targetMC;
}
}
Sample swf:
[flash]http://www.blog.lessrain.com/wp-content/upload/Untitled1.swf,400,400[/flash]