In this experiment we use a simplified and easier to customize version of our very popular BitmapSphere class presented in Texture Mapping in AS3 and Flash CS3: a Bitmap Sphere. In this version the class contains only basic rendering and texture mapping functionality. The class has a simple public rotation method. Click on the image below to open the applet in a new window.
- Download all the source files corresponding to this experiment: planets.zip
All the source files are exhausively commented and should be easy to follow.
All you need to do to use your own collection of images, is to change the line in planets.fla file (contained in the package) that reads:
and insert names of your image files (or their addresses if they are not in the same directory as the html file containing the applet). Customizing all the rotational functionality (auto rotation and rotation with the mouse) can also be done in the planets.fla file.
The AS3 GlowFilter Class
For each of the bodies, we use an instance of the GlowFilter with different parameters. The constructor of the GlowFilter class evoked with the keyword 'new' takes the following parameters (the default values shown).
'color' determines the color of the glow, 'alpha' its transparency, 'blurX' the amount of horizontal stretch of the glow, and 'blurY' the amount of vertical stretch. 'strength' controls the intensity of the spread and has a dramatic effect on the apppearnce of the glow, 'quality' determines how many times the filter is applied for smoother appearance and a larger area of the glow. 'inner' set to 'true' produces the inner glow; knockout set to 'true' makes the object transparent and only its glow visible.
In planets.fla, each time a new image is loaded, we create an instance of BitmapSphereBasic stored in the variable 'ball'. Here are examples of the filters applied with some of our planets (and Phobos which is a moon of Mars and not a planet):
ball.filters =[ new GlowFilter(0xBCF1FE,0.6,60.0,60.0,1) ];
ball.filters =[ new GlowFilter(0xB4B5FE,0.6,32.0,32.0,1) ];
Phobos has no filter:
On the nxet page, we dicuss the public methods of the custom BitmapSphereBasic class.