I need to code both hideEffect and showEffect to be shown when selecting different elements in a ViewStack.
For the showEffect, I need container to appear in a minimal size from the middle of the screen until it reaches its full size.
For the hideEffect, I need the exact opposite of that: to decrease the size of the container until it reaches a minimal size.
The alpha in both effects should change also (but that's a future problem)
I got the hideEffect covered with this:
<s:Scale id="hideEffect" scaleXFrom="1" scaleXTo="0.1" scaleYFrom="1" scaleYTo="0.1" autoCenterTransform="true" duration="200"/>
This makes the container disappear by decreasing its size.
I am having trouble with the showEffect.
If I put this:
<s:Animate id="showEffect"> <s:SimpleMotionPath property="x" valueFrom="512" valueTo="0"/> <s:SimpleMotionPath property="y" valueFrom="384" valueTo="0"/> <s:SimpleMotionPath property="scaleX" valueFrom="0.1" valueTo="1"/> <s:SimpleMotionPath property="scaleY" valueFrom="0.1" valueTo="1"/> </s:Animate>
The container appears from the upper left corner of the screen. I guess this has to do with the fact that the container doesn't know which its final "center".
That is why I tried the second solution, but with no luck.
If I only set the "x" and "y" properties in the Animate effect, the container appears in the middle and moves towards the (0,0) coordinates. But when I add the scaleX and scaleY properties, the container is first shown in the middle (for a veeeeeeeeeeeeeeeeery brief moment) but then appears in (0,0) and it increases size from there.
Can anyone shed a light on this?
Well the issue is well know among the undergorund of flex.
See, to achieve what you need, to would have to tell flex to apply those effects that depends on the final x and y of the object, once that the object is already on the laoyout.
In order to do that, you have to add applyChangesPostLayout="true" to the scale effect object declaration.
A different approach, I believe, would be to play with the addChild tag on the transicitions, but that my frinend is a different story.
Try this and enjoy your scale!
You are the man!