Game Development Reference
In-Depth Information
The following is a private function that is called from the constructor of the
SpriteTest class:
private function addBackground():void {
var bma:BitmapAsset = new Back() as BitmapAsset;
var back:Sprite;
back = new Sprite();
back.graphics.beginBitmapFill(bma.bitmapData);
back.graphics.drawRect(0, 0, WIDTH, HEIGHT);
back.graphics.endFill();
addChild(back);
}
The result of the earlier changes looks like what's shown next:
Notice that the background is added first into the stage and then the bee is. The order
of adding the sprites is important. By reversing the order, you will not be able to put
the bee on top of the background.
Here is the full listing of our program so far:
package {
import flash.display.Sprite;
import flash.events.TimerEvent;
import flash.utils.Timer;
import mx.core.BitmapAsset;
public class SpriteTest extends Sprite
{
[Embed(source="rsrc\\back.png")]
 
Search WWH ::




Custom Search