Simulated 3d in Flash

This is just some code tossed together to allow you to scale an object based on its distance from the view.


    size = function (clip:MovieClip, Angle:Number, Distance:Number, xsize:Number, ysize:Number) {
        clip._xscale = xsize/((57.3*Distance)/Angle);
        clip._yscale = ysize/((57.3*Distance)/Angle);
    };

works really well. The distance is the linear distance from the view to the target. X and Y size are the original size of the movie clip. (probably a better way of doing it) the Angle is actually the width of the view in degrees. This was all based off the equation for figuring out focal length that is in most physics books.

Ok, so its probably nothing major but I figured I’d post it as an example for anyone to use.