首先,我不是Flex的专家,所以下面可能是101个问题。
我的第一个问题是,我试图将一组对象旋转90度,这些对象包含在画布中,每个对象的大小都是一致的,其中包含文本和图像。我的第一个问题是,旋转对象会导致它们调整到自身的边界。例如,如果对象是200x250,图像从0延伸到250像素,旋转后内容将调整为200像素,这意味着图像现在是200像素。随后,我可以将对象的大小调整回适当的尺寸,但感觉很笨拙。有没有一种更好的方式来执行这种旋转,它旋转对象而不被限制在对象的边界内?
其次,理想情况下,我需要此代码在creationComplete事件中运行。当它这样做时,对象的定位/居中被忽略,并且在屏幕上呈现时是不同的(例如,如果我在单击事件中运行以下代码,它将完全围绕其中心点旋转;通过creationComplete它偏移对象,就像中心点不存在一样)?
有什么建议吗?
我的循环代码..。
<mx:Script>
<![CDATA[
// Capture the init for the application
private function InitialRotate( e:Event ):void{
var offsetWidth:Number = (this.width / 2);
var offsetHeight:Number = this.y + (this.height / 2);
// Rotates on the center (but resizes)
var tempMatrix:Matrix = this.transform.matrix;
tempMatrix.translate(-offsetWidth,-offsetHeight);
tempMatrix.rotate(90 * (Math.PI / 180));
tempMatrix.translate(+offsetWidth,+offsetHeight);
this.transform.matrix = tempMatrix;
// Adjusts the objects position and width to size appropriately
this.y -= 5.5;
this.width = 256;
}
]]>
</mx:Script>发布于 2012-04-18 03:07:20
我使用了spark rect类(recently.spark.primitives.supportClasses.GraphicElement.rotation)的旋转属性,它非常简单,如下所示
line.rotation=90;也许这个博客会有帮助:http://blog.flexexamples.com/2007/09/14/rotating-images-using-the-matrix-class/
https://stackoverflow.com/questions/10190953
复制相似问题