开发者

In flex How to create a trapezoid shape with the Class of Matrix? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center开发者_Go百科. Closed 11 years ago.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜