In flex How to create a trapezoid shape with the Class of Matrix? [closed]
I want to use Image Reflection in trapezoid shape. That why i ask how to create trapezoid shape with the class of matrix
For shear mathematical reasons you can't achieve this with the Matrix class per se.
However, the effect you are looking to achieve, i.e., having an image or component reflection look as though it has 3D perspective, can be achieved as long as you are compiling for Flash Player 10, or greater. You can do this using the Matrix3D class, which allows you to affect pseudo-3D transformations (projective transformations) in Flash.
Example
In the MXML:
<mx:Image id="img" source="@Embed('image.jpg')"/>
<mx:Image id="reflection" source="{img.source}"
creationComplete="reflectImage()"/>
and in the script block:
protected function reflectImage():void
{
var m3D:Matrix3D = new Matrix3D();
m3D.appendScale(1,-1,-1); // flip the image
m3D.appendTranslation(0,img.height,0); // move it back to (0,0,0)
m3D.appendRotation(-45, Vector3D.X_AXIS); // rotate it (this gives it the trapezoid shape)
m3D.appendTranslation(0,img.height,0); // move to the bottom of "img"
reflection.transform.matrix3D = m3D;
}
You'll probably want to play with the numbers a bit to affect the look you're going for, but this is the way to go about it.
Note: Any transformations (like setting x, y ) in the MXML will be overridden by the reflectImage
function.
精彩评论