Tito Posted February 15, 2012 Share Posted February 15, 2012 There's been a number of questions on how to clone a imageLoader.getContent, so I thought I'd chuck in a slightly more complete solution so people don't have to waste time doing it. package com.optricks.Tools { import flash.display.Bitmap; import flash.display.BitmapData; import flash.display.Sprite; import flash.geom.Matrix; import flash.display.DisplayObject; import flash.geom.Rectangle; /** * ... * @author Tito */ public class ImageTools { private static const _myType :String = "ImageTools"; public static function cloneImage(image:DisplayObject) :DisplayObject { var bmd :BitmapData; var bitmap :Bitmap; var spr :Sprite; var bounds :Rectangle = image.getBounds(image); bmd = new BitmapData(int(bounds.width + 0.5), int(bounds.height + 0.5), true, 0x0); bmd.draw(image, new Matrix(1, 0, 0, 1, -bounds.x, -bounds.y)); bitmap = new Bitmap(bmd, "auto", true); bitmap.x = bounds.x; bitmap.y = bounds.y; spr = new Sprite(); spr.addChild(bitmap); return spr; } }} Hope this saves you 20 minutes Link to comment Share on other sites More sharing options...
Carl Posted February 15, 2012 Share Posted February 15, 2012 thanks for sharing. I'll take it for a spin. Link to comment Share on other sites More sharing options...
mspanish Posted February 29, 2012 Share Posted February 29, 2012 Hi Tito any way you can give an example of how to use this? Link to comment Share on other sites More sharing options...
mspanish Posted February 29, 2012 Share Posted February 29, 2012 Hi Tito I got this working great but the images look terrible - really fuzzy. Adding smoothing didn't help. Have you found any way to get the bitmap images a bit smoother? Link to comment Share on other sites More sharing options...
mspanish Posted February 29, 2012 Share Posted February 29, 2012 Ok I had some thumb resizing going on that I didn't realize - so now the bitmap thumbs aren't too bad. But I'd still like to send over a COPY of the SWF to the subject, rather than the thumbnail SWF - otherwise the user can only put 1 of those items on the screen, 1 time - they can't ever access that item again without reloading all of the thumbs. So I need to find a way to create a duplicate of the ContentDisplay object on the fly, whenever the user clicks on it. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now