This is working, but is this a good example of polymorphism?
package mtm.test
{
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.MovieClip;
public class TestDocument extends MovieClip
{
public function TestDocument()
{
var image:Image = new Image();
image.id = 0;
image.bitmaps[BitmapFullSize] = new BitmapFullSize(new BitmapData(400, 400, false, 0x000000));
image.bitmaps[BitmapMediumSize] = new BitmapMediumSize(new BitmapData(250, 250, false, 0x000000));
image.bitmaps[BitmapThumbnail] = new BitmapThumbnail(new BitmapData(65, 65, false, 0x000000));
var bmp:BitmapType = image.bitmaps[BitmapFullSize];
if(bmp != null) addChild(bmp);
}
}
}
Here are the classes used above:
package mtm.test
{
import flash.display.Bitmap;
public dynamic class Image extends Object
{
public var id:int;
public var enabled:int;
public var orderNum:int;
public var filename:String;
public var title:String;
public var description:String;
public var medExists:int;
public var fullExists:int;
public var thumbExists:int;
public var bitmaps:Object = new Object();
}
}
BitmapType Parent Class
package mtm.test
{
import flash.display.Bitmap;
import flash.display.BitmapData;
public class BitmapType extends Bitmap
{
public function BitmapType(bitmapData:BitmapData = null, pixelSnapping:String = 'auto', smoothing:Boolean = false)
{
super(bitmapData, pixelSnapping, smoothing);
}
}
}
Sub-Classes of BitmapType
package mtm.test
{
import flash.display.BitmapData;
public class BitmapFullSize extends BitmapType
{
public function BitmapFullSize(bitmapData:BitmapData = null, pixelSnapping:String = 'auto', smoothing:Boolean = false)
{
super(bitmapData, pixelSnapping, smoothing);
}
}
}
package mtm.test
{
import flash.display.BitmapData;
public class BitmapMediumSize extends BitmapType
{
public function BitmapMediumSize(bitmapData:BitmapData = null, pixelSnapping:String = 'auto', smoothing:Boolean = false)
{
super(bitmapData, pixelSnapping, smoothing);
}
}
}
package mtm.test
{
import flash.display.BitmapData;
public class BitmapThumbnail extends BitmapType
{
public function BitmapThumbnail(bitmapData:BitmapData = null, pixelSnapping:String = 'auto', smoothing:Boolean = false)
{
super(bitmapData, pixelSnapping, smoothing);
}
}
}