`
bzhang
  • 浏览: 253508 次
  • 性别: Icon_minigender_1
  • 来自: 大连
社区版块
存档分类
最新评论

Stop using mx.transitions.Tween

    博客分类:
  • FLEX
阅读更多

zz from:http://www.psyked.co.uk/adobe/flash/stop-using-mxtransitionstween.htm

 

If you’re still using Flash’s inbuilt Tween classes for you scripted animations, I suggest you stop - and start making things easier for yourself by using Tweener instead. Tweener is a class that replaces Tween, works for Actionscript 2 and Actionscript 3, offers a simpler interface for creating tweens, and has a larger range of easing options to work with.

What’s wrong with Tween?

The Tween class is ok - up to a point. It does what it’s supposed to, but once you start trying to integrate it with serious full-on Actionscripting you’ll notice a few snags. If you’re dynamically creating and removing objects, and then want to dynamically modify the tweens, your tweens will likely go crazy. Start a new Tween and there’s very little way you can stop it - even by removing its subject. Stacking Tweens doesn’t go down well either - if you create one to move an object left to right, and then mid-animation another to move it back to the left, things go ok until the point that the first animation should finish - whereupon your object will flick back to the finishing position of the first, and then resume the second animation.

Moreso than that however, is the hassle needed to create an animation with Tween;

import mx.transitions.Tween;


import mx.transitions.easing.*;


var xPosT:Tween = new Tween(myMovieClip, "_x", Bounce.easeOut, 0,
Stage.width, 3, true);


xPosT.onMotionFinished = function() {


// movement finished


};

Why is Tweener better?

First up, there’s no problems with mixing and matching, no misplaced motion crazyness.  You can apply and reapply tweens to your hearts content, and they all work.

Secondly, the interface is simpler - you can setup a tween with less lines of code, and you don’t have to worry about managing objects to execute functions once your tween has run its course. And a single line of code can handle all of the attributes you want changing for a single object - no separate Tween objects for each attribute, just a single Tweener line for all the attributes (on the same object, under the same time and easing style).

import caurina.transitions.Tweener;

Tweener.addTween(myMovieClip, {_x:Stage.width, time:1, transition:"linear",
 onComplete:onCompleteHandler});

function onCompleteHander():Void {
// movement finished


};

Thirdly, you don’t have to worry about things like start variables - just the end variables.  Which makes far more sense.  In most situations I find I’m only adding the current position of an object as the start variable to Tween.  In Tweener, that’s taken as the automatic variable - after all, if you want to set a different position for the object before the tween starts, you just do that on the line above.

Lastly, there’s a invaluable delay attribute.  It’s a built-in timer for your animations - how useful is that!  Want an animation to start after 10 seconds? Easy - just add ‘delay:10′ to your Tweener line.

分享到:
评论

相关推荐

    fl.transitions,fl.tweens包等都有

    在ActionScript 3 (AS3)中,`fl.transitions` 和 `fl.tweens` 包是Adobe Flex SDK的一部分,用于实现丰富的动画效果和过渡。这两个包提供了许多类和方法,帮助开发者创建出平滑、动态的用户界面,增强应用程序的视觉...

    tweener包 flash缓动

    - Tween类的方法返回的是Tween对象本身,因此可以进行链式调用,方便地设置多个动画效果。例如:`Tween.to(object).to(newPosition, duration).ease(Ease.QuadInOut)`。 4. **插值计算**: - Tweener库内部实现了...

    Using CiviCRM.epub

    Overall, your organization will interact with constituents more effectively and handle staff growth and transitions by tracking all contacts and interactions with them in a system shared across the ...

    Flash幻灯片制作.pdf

    mx.transitions.TransitionManager.start (eventObj.target, {type:mx.transitions.PixelDissolve, direction:0, duration:2, easing:mx.transitions.easing.None.easeNone, xSections:10, ySections:10});...

    timage.zip_transitions

    在IT行业中,"timage.zip_transitions"这个标题暗示了一个关于图像处理或动画效果的资源包,特别是与过渡效果相关的。这里的"transitions"标签进一步证实了这一点,它通常指的是在图像、视频或UI设计中,一个状态...

    Flex 仿SOHU高清首页图片切换广告 xml配置文件

    为了实现图片的平滑切换效果,Flex中的`mx.transitions`包提供了多种过渡效果和动画类。开发者可能使用`Timeline`或`Tween`类来控制图片切换的动画效果,例如淡入淡出、滑动等。 5. **事件处理**: Flex事件模型...

    transitions-everywhere-android4.4和5.0中Transitions API的兼容补丁,可兼容2.2 .zip

    在原本需要使用android.transition.*的地方使用android.transitions.everywhere.*。如果你想在xml文件中使用transition,不要将xml放在res/anim,而是放在res/transition目录。同时你需要使用将命名空间改为app 而...

    Transitions and Animations in CSS3

    CSS transforms, CSS transitions, and CSS animations are three separate CSS specifi‐ cations. While the three terms sound like they may do the same thing—make some‐ thing move—CSS transitions and ...

    Transitions-call-system.rar_transitions

    在这个“Transitions-call-system.rar_transitions”压缩包中,我们可以推测包含的是一个关于单工呼叫系统的实现源代码。"程序"这个文件名可能是源代码的主文件或者包含了所有相关代码的文件夹。通过分析和学习这个...

    Tweener 缓动类 (AS3)

    这个引擎的主类是 caurina.transitions.Tweener。 Tweener的语法很容易适应。与Adobe的Tween类不同,你不需要实例化主类Tweener。而是调用Tweener的静态方法。主要的方法是addTween。就像这样: Tweener.addTween...

    AngularJS - Novice to Ninja.pdf.pdf )

    非常不错的书 Preface . . . . . . . . ....Who Should Read This Book ....Conventions Used ....Code Samples ....Tips, Notes, and Warnings ....Supplementary Materials .... ....Chapter 1 Falling In Love With AngularJS ....

    Python有限状态机——transitions

    Python中的有限状态机库——`transitions`是一个强大的工具,用于在对象之间管理状态转换。这个库使得在Python代码中实现复杂的状态逻辑变得简洁而直观。`transitions`库不仅适用于简单的状态切换,还能处理条件触发...

    html5图片切换jquery css3 Transitions...

    在“HTML5图片切换jquery css3 Transitions...”这个主题中,我们将深入探讨如何利用这些技术实现优雅的图片切换效果。 首先,HTML5是超文本标记语言的最新版本,它引入了许多新特性,比如离线存储、媒体元素、 ...

    Android Material Transitions.zip

    这个压缩包"Android Material Transitions.zip"包含了一个名为"MaterialTransitions-master"的项目,很可能是用来演示和学习Android Material Design过渡动画的示例代码。 Android Material Transitions主要涉及...

    Transitions-150组视频转场动画

    标题中的“Transitions-150组视频转场动画”是指一个包含150个不同视频转场效果的资源集合,这些转场效果是专为Adobe After Effects(简称AE)2018版本设计的。在视频编辑和制作中,转场动画用于连接不同的视频片段...

    transitions:Cocos Creator的过渡效果

    // Use **transitions.loadScene** instead of **cc.director.loadScene** // cc.director.loadScene(url, this.onLoadSceneFinish.bind(this)); this . transitions . loadScene ( url , 'Canvas/Main Camera' , '...

    Android代码-Transitions-Everywhere

    Article about Support Library for Transitions. Overview and comparison with Transitions-Everywhere Simple example TransitionManager.beginDelayedTransition(transitionsContainer); text.setVisibility...

Global site tag (gtag.js) - Google Analytics