Yet another weird actionscript problem that’s been bothering me for some time. I’m trying to make a BitmapData snapshot of a Flex Component and then transform it with a Matrix. Quite simple you would say, this is how you would do it:
1 2 3 4 5 | var flippedBmd:BitmapData = new BitmapData(myUIComponent.width, myUIComponent.height, true, 0xFFCC00); var flipMatrix:Matrix = new Matrix(); flipMatrix.scale(-1, 1); flipMatrix.translate(myUIComponent.width, 0); flippedBmd.draw(myUIComponent, flipMatrix); |
Where myUiComponent is any Flex Component instance.
This all works well, except for the text in the Component, all ‘dynamic’ texts won’t show in the BitmapData, whil everything works well if I comment out the flipmatrix.scale and flipmatrix.translate lines.
You can see this weird behavior in action here. Try it by clicking the ‘Flip’ button.
The first one who gives me a BitmapData-only solution to this problem deserves a free beer!
You can get this to work using just BitmapData by doing an untransformed snapshot first and then applying the transformation to the snapshot bitmap data. So in your example, you would replace the last line with:
var snapBmd:BitmapData = new BitmapData(myUIComponent.width, myUIComponent.height);
snapBmd.draw(myUIComponent);
flippedBmd.draw(snapBmd, flipMatrix);
Can we have a reflection for transparent or rounded corner objects. Currently rectangular border is displaying along with reflection.