Search code examples
flex4flex-spark

Rotate Spark TitleWindow


While I was trying to rotate Spark TitleWindow using the following code

<s:Rotate id="rotate"  angleBy="360" autoCenterTransform="true" target="{targtObj}"></s:Rotate>

it rotates around z-axis. How can I rotate by x-axis or y-axis maintaining the autoCenterTransform="true".


Solution

  • There is also a Spark Rotate3D effect, which enables one to rotate about the other axes. Unfortunately, it doesn't seem to have an equivalent angleBy property, only angleFrom and angleTo for each of the axes. If you are rotating 360°, then that isn't that big of a problem, since you would be ending at the starting point:

    <s:Rotate3D id="rotate3D" target="{targtObj}"
                angleYFrom="0" angleYTo="360"
                autoCenterTransform="true" />
    

    Even if you weren't ending at the starting point, getting the same effect as the angleBy is still a rather simple matter. Here is a 30° rotation about the Y-Axis:

    <fx:Number id="lastAngle">0</fx:Number>
    <s:Rotate3D id="rotate3D" target="{targtObj}"
                angleYFrom="{lastAngle}" angleYTo="{lastAngle+30}"
                autoCenterTransform="true" effectEnd="lastAngle+=30"/>