So the custom class which would need to reside in a custom_class.as file would look like this:
package {
import flash.display.Bitmap;
import flash.display.BitmapData;
public class custom_class extends Bitmap {
public var our_new_property:String = "Blah";
// We will call super in our constructor.
public function custom_class(image:BitmapData = null) {
super(image);
}
}
}
To use this class, the code would look like this:
// Embed a image to use
[Embed(source="my_image.png")]
[Bindable]
private var image:Class;
private var tmp_image:Bitmap = new image();
private var custom_image:custom_class =
new custom_class(tmp_image.bitmapData);
// Now our custom properties and all
// the Bitmap properties are accessible
custom_image.our_new_property = "some string value";
custom_image.x = some x value;
stage.addChild(custom_image); // Will now get displayed on the stage.
No comments:
Post a Comment