如何在 Flex 4.5 应用程序中使用 MovieClips 补间?
我是 Flex 新手,正在尝试将纯 Flash/AS3 纸牌游戏 移植到弹性 4.5。
它大部分工作得很好,但我在那里遗漏了一些谜题部分:
我创建了一个基于 UIComponent 的自定义组件,表示一副纸牌(它们是 Sprites 或 MovieClip 的数组):
在最初的纯 Flash/AS3 游戏中,我对桌上的 3 张牌使用了 Tween - 向游戏用户显示谁放了哪张牌(通过将它们滑向打表中间):
import fl.transitions.*;
import fl.transitions.easing.*;
public class Deck extends UIComponent {
private var _card:Array = new Array(3);
private var _tween:Array = new Array(3);
....
override protected function createChildren():void {
_tween[YOU] = new Tween(_card[0], 'y', Regular.easeOut, _card[0].y + 40, _card[0].y, .5, true);
_tween[LEFT] = new Tween(_card[1], 'x', Regular.easeOut, _card[1].x - 40, _card[1].x, .5, true);
_tween[RIGHT] = new Tween(_card[2], 'x', Regular.easeOut, _card[2].x + 40, _card[2].x, .5, true);
....
但是Flash Builder 4.5似乎根本不知道fl.transitions.*包?
有人对如何使用 有建议吗补间在这里?
就像我写的其余部分(我的自定义 Flex 组件、移动卡片精灵等)效果很好。只有 Tween 行需要注释。
谢谢你! 亚历克斯
I'm new to Flex and am trying to port a pure Flash/AS3 card game to Flex 4.5.
It works mostly well, but I'm missing few puzzle parts there:
I've created a custom component based on UIComponent representing a deck of cards (which are an array of Sprites or MovieClips):
In the original pure Flash/AS3 game I was using Tween for the 3 cards at the table - to show the game user, who has put which card (by sliding them towards playing table middle):
import fl.transitions.*;
import fl.transitions.easing.*;
public class Deck extends UIComponent {
private var _card:Array = new Array(3);
private var _tween:Array = new Array(3);
....
override protected function createChildren():void {
_tween[YOU] = new Tween(_card[0], 'y', Regular.easeOut, _card[0].y + 40, _card[0].y, .5, true);
_tween[LEFT] = new Tween(_card[1], 'x', Regular.easeOut, _card[1].x - 40, _card[1].x, .5, true);
_tween[RIGHT] = new Tween(_card[2], 'x', Regular.easeOut, _card[2].x + 40, _card[2].x, .5, true);
....
However Flash Builder 4.5 doesn't seem to know fl.transitions.* packages at all?
Does anybody please have an advice on how to use Tween here?
Like I've written the rest (my custom Flex component, moving card-Sprites around, etc.) works well. Only the Tween lines had to be commented.
Thank you!
Alex
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
查看 Google 代码上的 Tweener 类。使用它,您可以指定对象、其属性及其所需值的映射以及时间,并且它将这些属性从当前值“补间”到所需值。
Take a look at the Tweener class on Google Code. With it you can specify and object, and a map of its properties and their desired values, along with time, and it will 'tween' those properties from their current to their desired values.
我的第一个下意识反应是将 flash.swc(由 Flash CS Pro 提供)添加到 Flex 构建路径中,然后:
可以再次使用。
但从长远来看,我可能会编写自己的函数来移动扑克牌并运行它事件。ENTER_FRAME。因为我不想仅仅为了卡片滑动而包含 Tweener 或 Tweenlite 库。
我还查看了 mx.effects.Tween 和 Spark.effects.Animate,但它们似乎更适合 UIComponent,而不是像我这样的 Sprites。
My first knee-jerk reaction has been to add flash.swc (delivered by Flash CS Pro) to the Flex build path and then:
can be used again.
But in the long-term I will probably write my own function to move the playing cards and run it on Event.ENTER_FRAME. Because I don't want to include Tweener or Tweenlite libraries for mere card sliding.
Also I've looked at mx.effects.Tween and spark.effects.Animate but they seem to be more appropriate for UIComponents and not Sprites as in my case.