1

flex 有另一个小问题......我做了一个椭圆,我想动态旋转它。制作了 ah:slider,它改变了椭圆的 rotate="" 值。它旋转得很好。但旋转点在椭圆的中间。

我想要它在底部(y)和中间(x)。

椭圆有一些 transformY 和 transformX 参数,但它们没有效果?

我的功能

private function rotateRadius():void {
if(wind.selected) {

selected.radiusDisp.rotation = radiusRotate.value;
}else {

}

}

如果有人能给我一个提示,那就太好了

4

2 回答 2

1

这是改变对象旋转方式的最简单方法。

<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

于 2011-06-18T21:11:04.183 回答
0

有几种方法可以做到这一点,可能最简单的方法是将椭圆嵌套在另一个显示对象中(以便您要旋转的点位于新显示对象的中心)。这对于 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

于 2011-06-18T17:08:37.737 回答