I have a container displaying several elements and I want to create a bitmap representing some of them together.
Since I do not want to remove the elements from their owner, I use a second container in which I insert a bitmap created for each element. Then I produce a bitmap from this second container. The algorithm looks like this:
const selectionGroup:Group = new Group();
for each ( var element:UIComponent in selectedElements ) {
const image:Image = new Image();
image.x = element.x;
image.y = element.y;
image.source = createBitmapFrom( element );
selectionGroup.addElement( image );
}
return createBitmapFrom( selectionGroup );
However, the final bitmap never contains anything unless I display the group somewhere. Eventually I can also remove it as soon as the creationComplete event is dispatched but I do not like this solution since it makes the interface to flicker.
I tried to insert the elements in a BoarderContainer instead of a Group, with creationPolicy set to "all", and calling createDeferedContent() before the final createBitmapFrom(), but the image is still transparent.
So, the next solution would be to compose the final bitmap from the various sub bitmaps, unless someone tells me how to capture a component that is never displayed.
How can I tell to Flex to create the content of the component without displaying it?