In my recent posting on Flash Bitmap maximum width and height, I blog about how Flash bitmapData object has a maximum width and height of 2880 pixel . I was recently contacted by John Keyton who was really nice to point a work around created by Ronald Losbañes that would allow you to create a bitmapData object that is bigger than 2880 pixel in height and width . Here’s the workaround from Ronald Losbañes site.
The trick is to “kidnap” a BitmapData object from a loaded image with dimension over the limit of 2880 pixels (Which flash allows. Huh! Yes Flash can actually handle bitmaps larger the the limit. It just doesn’t let you create one.).
It’s simple. Create a dummy image with the dimension you need. Save it and make it accessible to Flash. Dynamically load it using ActionScript. And take the loader object’s BitmapData object. That’s why I termed it “kidnap”. We are actually just taking the child of the parent object(loader object), which is the BitmapData, and use it like we build it ourselves.
Here’s the actionscript ,
// 1. Create an image loader and var DummyImageLoader:Loader = new Loader; // 2. Assign a function to “kidnap” the BitmapData object DummyImageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, DummyImageOnComplete); // 3. Load the image with the preferred dimension var DummyImageRequest:URLRequest = new URLRequest(“dummy_image.jpg”); DummyImageLoader.load(DummyImageRequest); function DummyImageOnComplete(evt:Event):void { var DummyImageBitmap = Bitmap(DummyImageLoader.content); // “kidnap” the BitmapData object var ValidBitmapData:BitmapData = DummyImageBitmap.bitmapData; // you can now use ValidBitmapData to draw any element larger than 2880×2880 } var InvalidBitmapData:BitmapData = new BitmapData(3000, 3000); |
Big thanks to John to pointing out the link to me and Ronald Losbañes for the solution.
