The BitmapSphereBasic class differs significantly from BitmapSphere class introduced in our tutorial Texture Mapping in AS3 and Flash CS3: a Bitmap Sphere. BitmapSphere was responsible for creating a background for a sphere and for the rotation with the mouse functionality. In this version, the class is only responsible for basic rendering and texture mapping functionality and provides a simple public rotation method.
Public Methods
The BitmapSphereBasic class has three public methods.
The constructor:
The constructor of the BitmapSphereBasic class, evoked with the keyword 'new', takes only one parameter: a BitmapData object. This BitmapData object corresponds to the image to be pasted over a sphere. The radius of the sphere is determined by the class based on the dimensions of the BitmapData parameter passed to the constructor. For best results the image's width and height should have 2 to 1 ratio. Otherwise clipping or streching will occur. In planets.fla, we create instances of the class with BitmapData objects corresponding to loaded images. The BitmapData objects are stored in the variable imageData:
ball=new BitmapSphereBasic(imageData);
'goRotate' Method
The method takes two parameters:
instance.goRotate(t:Number,p:Number)
The first parameter produces horizontal angular displacemet of the observer by t degrees. The second parameter produces vertical angular displacemet of the observer by p degrees.
'destroy' MethodThe method takes no parameters. It should be called by an instance before the instance is deleted. The method clears all objects created by the instance. For example, in planets.fla, before loading the next image, we clear the previous sphere:
ball.destroy();
Download
- Download all the source files corresponding to this experiment: planets.zip











