got another little provlem with flex ... i've made a ellipse and i want to rotate it dynamicly. made a h:slider which change the rotate="" value of the ellipse. and it rotates fine. but the rotation point is in the middle of the ellipse.
i want it at the bottom (y) and middle (x).
there are some transform开发者_运维技巧Y and transformX arguments for the ellipse, but they have no effect?
my function
private function rotateRadius():void {
if(wind.selected) {
selected.radiusDisp.rotation = radiusRotate.value;
}else {
}
}
would be great if someone can give me a hint
That is the simplest way to change the way an object is rotating.
<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>
If you want your ellipse to rock/roll on the surface, you need to add a bit trigonometry to calculation of the registration point.
HTH, FTQuest
There are a few ways to do that, probably the easiest is to nest your ellipse within another display object (so that the point you want to rotate by is at the center of the new display object). This can be a pain with flex layout though as you now have a 'bigger' object than your ellipse there.
The other option (the correct way) is to use the transform object, see
http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/DisplayObject.html#transform
and
http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/geom/Transform.html#matrix
精彩评论