我怎样才能在视图堆栈之间很好地制作动画
我有一个 Adobe Air 小应用程序,我想在其中拥有多个“视图”。 我可以使用 ViewStack 实现这些视图,但很难找到一种在它们之间进行动画处理的好方法。
这是我尝试过的方法,虽然它有效,但当我想要的更像是 DestroyTwitter 应用程序时,一个视图会在滑入视图之前消失,其中视图和所有控件都很好地滑出视图:
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="400" height="700" top="100" left="100" creationComplete="onComplete()">
<mx:Script>
<![CDATA[
import mx.core.Application;
private function onComplete():void
{
stack.selectedChild = stack1;
}
private function switchTab():void
{
if( stack.selectedChild == stack1 )
{
stack.selectedChild = stack2;
}
else
{
stack.selectedChild = stack1;
}
}
]]>
</mx:Script>
<mx:Move id="slideLeft" xFrom="{Application.application.width}" xTo="0" yTo="0" duration="500" />
<mx:Move id="slideRight" xFrom="0" xTo="{Application.application.width}" duration="500" />
<mx:ViewStack id="stack" width="200%" height="100%">
<mx:VBox id="stack1" width="100%" height="100%" backgroundColor="white" hideEffect="{slideRight}" >
<mx:Label text="Stack 1" />
<mx:Button label="Switch" click="switchTab()" />
</mx:VBox>
<mx:VBox id="stack2" width="100%" height="100%" backgroundColor="#cdcdcd" hideEffect="{slideLeft}" >
<mx:Label text="Stack 2" />
<mx:Button label="Switch" click="switchTab()" />
</mx:VBox>
</mx:ViewStack>
</mx:WindowedApplication>
有没有人有任何更好的想法可以尝试,是感谢任何回应?
I have a little Adobe Air app and I want to have several 'views' within it. I can achieve these views using a ViewStack but am having difficulty finding a nice way to animate between them.
This is what I have tried and although it works, one view disappears before sliding into view when what I want is more like the DestroyTwitter app where the view and all controls slide out of view nicely:
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="400" height="700" top="100" left="100" creationComplete="onComplete()">
<mx:Script>
<![CDATA[
import mx.core.Application;
private function onComplete():void
{
stack.selectedChild = stack1;
}
private function switchTab():void
{
if( stack.selectedChild == stack1 )
{
stack.selectedChild = stack2;
}
else
{
stack.selectedChild = stack1;
}
}
]]>
</mx:Script>
<mx:Move id="slideLeft" xFrom="{Application.application.width}" xTo="0" yTo="0" duration="500" />
<mx:Move id="slideRight" xFrom="0" xTo="{Application.application.width}" duration="500" />
<mx:ViewStack id="stack" width="200%" height="100%">
<mx:VBox id="stack1" width="100%" height="100%" backgroundColor="white" hideEffect="{slideRight}" >
<mx:Label text="Stack 1" />
<mx:Button label="Switch" click="switchTab()" />
</mx:VBox>
<mx:VBox id="stack2" width="100%" height="100%" backgroundColor="#cdcdcd" hideEffect="{slideLeft}" >
<mx:Label text="Stack 2" />
<mx:Button label="Switch" click="switchTab()" />
</mx:VBox>
</mx:ViewStack>
</mx:WindowedApplication>
Has anyone got any nicer ideas to try, be grateful for any response?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以尝试的一件事是更高级地切换视图。 单击“切换”按钮后,执行移动,直到移动完成后才进行交换。
也许是这样的:
One thing you can try is a little more advanced swapping in and out of views. When the 'switch' button is clicked, perform the move and don't do the swap until the move is finished.
Perhaps something like this:
将模糊添加到上面接受的答案中。 使过渡看起来更平滑/更酷。
我试图从这个很酷的 Arduino 速度计复制状态转换 迈克·钱伯斯,丹的回答加上一些模糊就达到了目的。
Add Blur to the accepted answer above. Makes the transition look smoother/cooler.
I was trying to replicate the state transitions from this cool Arduino speedometer by Mike Chambers, and the answer by Dan with some added Blur did the trick.
我将使用控制哪个视图处于活动状态的状态,然后定义在这些状态之间移动的转换:
http://livedocs.adobe.com/flex/3/html/help.html?content=transitions_3.html
I'd use states that control which view is active, and then define transitions for moving between those states:
http://livedocs.adobe.com/flex/3/html/help.html?content=transitions_3.html
这正是我想要实现的目标:
Here is exactly what i wanted to achieve: