Quantunet.com

My Account

Joins Us
Flash 8 Actionscript 2.0 Knowledgebase
2D Orbit With Perspective  

Download .fla

Actionscript

var radius = 80;
var perspective = 100;
var magnification = 100;
var degrees = 0;

onEnterFrame = function(){
angle = degrees * (Math.PI/180);
degrees += 2;

xposition = radius * Math.cos(angle);
zposition = radius * Math.sin(angle);

distance = 1 / (1-(zposition/perspective));

ball_mc._x = (xposition*distance) + Stage.width/2;

ball_mc._xscale = distance*magnification;
ball_mc._yscale = distance*magnification;

updateAfterEvent();
}

var radius = 80;
var perspective = 100;
var magnification = 100;
var degrees = 0;

onEnterFrame = function(){
angle = degrees * (Math.PI/180);
degrees += 2;

xposition = radius * Math.cos(angle);
zposition = radius * Math.sin(angle);

distance = 1 / (1-(zposition/perspective));

ball_mc._x = (xposition*distance) + Stage.width/2;

ball_mc._xscale = distance*magnification;
ball_mc._yscale = distance*magnification;

updateAfterEvent();
}


Note: movie clips can be dynamically scaled using the z axis as a reference. change perspective to formula: perspective = 1 /(1-Z/D);  D/(Z+D)


© 2008 Quantunet LLC All Rights Reserved | Intellectual Property | Terms of Use | Privacy
Home | About Quantunet | FAQ's | Contact Us