Here's the function I use (it uses getDefinitionByName & Class because it
lets me get bitmaps in externally loaded swfs as well):

  public static function getBitmapAsset(assetName:String):Bitmap {
   try {
    var ClassReference:Class = getDefinitionByName(assetName) as Class;
    var data:BitmapData = new ClassReference(0, 0);
   } catch (error:Error) {
    trace("AssetManager:: attempted to instantiate class (Bitmap) that was
not found (asset misnamed or does not exist in loaded libraries ",
assetName, error.toString());
   }
   var instance:Bitmap = new Bitmap(data);
   return instance;
  }



On Thu, Jun 19, 2008 at 4:11 PM, Ali Drongo <[EMAIL PROTECTED]>
wrote:

> Hello there, thanks for checking my post. I have a bunch of jpgs that I've
> imported into my library and have given class names, they default to extend
> the BitmapData class. When I try and instantiate them I get an error message
> saying I need to pass them 2 arguments. Here is my code:
>
> var formatImg = new LibImage();
>
> var image:Bitmap = new Bitmap(formatImg);
>
> mainMC.addChild(image);
>
> Could someone let me know the correct syntax for doing this?
> As I am using a document class I think I may need to use the
> [Embed(source='myPhoto.png')] syntax also
>
> Thanks!
> Ali
>
>
> _______________________________________________
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>



-- 
-jonathan howe :: 404.434.2321 :: 180 High St Apt 26 Portland, ME 04101
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to