Game Development Reference
In-Depth Information
have noticed an image in the MixUp.fla library that was set to export
This image of the Golden Gate Bridge in San Fran-
cisco (taken by yours truly circa 2003) will be available to us as raw
BitmapData when the SWF is exported. Back in the docu-
ment class, we also defined a list of image names (in this case, just
one image) that would be used to load in the data. Those names
were then used to create instances of a class called SourceIma-
geEmbedded. We
ll look at that class now.
public class SourceImageEmbedded implements ISourceImage {
private var _imageClass:Class;
private var _sourceBitmap:BitmapData;
private var _pieceList:Vector. < BitmapData > ;
public function SourceImageEmbedded(linkageName:String)
_imageClass = getDefinitionByName(linkageName) as
When a new SourceImageEmbedded object is created, the link-
age name in the library for the image we want to use is passed
into the constructor. That name is then used to look up and
retrieve the actual class that name is associated with. If you recall,
there were three required methods of the ISourceImage interface.
ll now look at this class
s implementation of those functions.
public function getImages(rows:int,
width:int = 0,
height:int = 0):Vector. < BitmapData > {
if (_pieceList) return _pieceList;
_sourceBitmap = new _imageClass(width, height);
var pieceBitmap:BitmapData;
var pieceWidth:int = Math.floor(_sourceBitmap.width /
var pieceHeight:int = Math.floor(_sourceBitmap.height / rows);
_pieceList = new Vector.
for (var j:int = 0; j
rows; j++) {
for (var i:int = 0; i
columns; i++) {
pieceBitmap = new BitmapData(pieceWidth,
var rect:Rectangle = new Rectangle(i * piece
Width, j * pieceHeight, pieceWidth,
rect, new Point());
Search Nedrilad ::

Custom Search