问题描述
弹性还有另一个小问题...
我做了一个椭圆,我想动态地旋转它。
制作了一个h:slider来更改椭圆的rotation = \“ \”值。
它旋转得很好。但旋转点在椭圆的中间。
我想要它在底部(y)和中间(x)。
椭圆有一些transformY和transformX参数,但是它们没有效果吗?
我的功能
private function rotateradius():void {
if(wind.selected) {
selected.radiusdisp.rotation = radiusRotate.value;
}else {
}
}
如果有人可以给我提示会很棒
解决方法
这是更改对象旋转方式的最简单方法。
<s:Application xmlns:fx=\"http://ns.adobe.com/mxml/2009\"
xmlns:s=\"library://ns.adobe.com/flex/spark\">
<s:controlBarContent>
<s:HSlider id=\"rotationSlider\" minimum=\"0\" maximum=\"360\" />
</s:controlBarContent>
<s:Ellipse rotation=\"{rotationSlider.value}\" transformX=\"100\" transformY=\"50\" width=\"200\" height=\"100\" x=\"100\" y=\"100\">
<s:fill>
<s:SolidColor color=\"red\" />
</s:fill>
</s:Ellipse>
<s:Ellipse rotation=\"{rotationSlider.value}\" transformX=\"100\" transformY=\"100\" width=\"200\" height=\"100\" x=\"400\" y=\"100\">
<s:fill>
<s:SolidColor color=\"red\" />
</s:fill>
</s:Ellipse>
如果希望椭圆在表面上摇摆/滚动,则需要在计算配准点时添加一点三角函数。
HTH,
FTQuest
, 有几种方法可以做到这一点,可能最简单的方法是将椭圆嵌套在另一个显示对象中(这样,您要旋转的点就位于新显示对象的中心)。使用flex布局可能会很麻烦,因为现在您有一个比椭圆更大的“更大”对象。
另一种选择(正确的方法)是使用转换对象,请参见
http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/DisplayObject.html#transform
和
http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/geom/Transform.html#matrix