This works. First define the new parameter.
[Inspectable(name = "image",type = String)]
public function set image (im:String):void
{
_image = im;
}
public function get image ():String
{
return _image;
}
Then in the component script you write this:
if (image != null)
{
var _Class:Object = getDefinitionByName(image) as Class;
myBitmap = new _Class(width,height);
var bMap:Bitmap = new Bitmap(myBitmap);
addChild (bMap);
}
Somewhere you define myBitmap and cast as BitmapData.
In the library you have a default image, here "dfaul". Click on the image in the library and go to properties and export for actionscript. Give a class name. I usually use the name of the image but without the extension. You have to do that with all the images in the library.




Reply With Quote
