I have an Image in a ImageViewer. I want to crop the image at runtime.
I can crop the bitmapdata of the image (infact, after that, I create a new bitmap with the new bitmapdata and put it on the stage and it's cropped), but I can't insert (change) the original bitmapdata of the original Image, because I need to continue working with that image....
I'm becoming crazy....
Please help me....
I'm unclear on what you are trying to do. You want to crop an Image element then replace the existing element with the new cropped image or you want to introduce a new Image instance with a cropped version of the original?
the first one.... I can't create an Image element with a particular Bitmap object in it....
the process I want to do is:
extract the Bitmap object form the Image element
substitute this new Bitmap object in the previous Image Element (or, at least, create a new Image element with the new Bitmap object, and delete the old Image).....
No problem. The bitmap reference of the Image element is a child of the Image so all you need to do is swap the child. It's easy to miss this by just searching the API but, in the future, I recommend investigating the source code to save yourself the headache. You can view/download the CML source here on github.
//crop original bitmap
var cropped:Bitmap = crop(image.bitmap);
image.bitmap = null;
//replace with cropped
image.bitmap = cropped;
//update image size
This topic is now closed. New replies are no longer allowed.
This topic is now archived. It is frozen and cannot be changed in any way.