 |
Poll: Favorite tween features? Feature wish list?
| Author |
Message |
|
elyon
Member
Joined: Wed Aug 01, 2007 3:37 pm Posts: 1220 Location: Grizzly Flats, CA
|
 Poll: Favorite tween features? Feature wish list?
What are your "must haves" when it comes to using a tween library?
What special properties (tint color, short rotation, etc) do you rely on?
If a tween engine could do more, or could be more perfect, what would be different, or what would it do?
Thanks!
|
| Mon Oct 26, 2009 5:31 pm |
|
 |
|
CourseVector
Member
Joined: Mon Jan 21, 2008 6:58 pm Posts: 45
|
 Re: Poll: Favorite tween features? Feature wish list?
For my use I rarely use more than the feature set in Tweenlite. I use autoAlpha almost everyday though. Rarely i'll mess with glow filters or color/tinting.
|
| Mon Oct 26, 2009 6:14 pm |
|
 |
|
FizixMan
Member
Joined: Thu Jul 26, 2007 7:06 pm Posts: 215 Location: Toronto, Ontario, Canada
|
 Re: Poll: Favorite tween features? Feature wish list?
I haven't used any tween engines (I write my own wrapper classes). That said, the primary usage for them I find is not changing properties directly but invoking delegated methods with the values passed in. In those methods I then set any properties or filters as I need.
I don't know if yours has that or not, but I thought I'd throw it out there.
|
| Mon Oct 26, 2009 7:09 pm |
|
 |
|
elyon
Member
Joined: Wed Aug 01, 2007 3:37 pm Posts: 1220 Location: Grizzly Flats, CA
|
 Re: Poll: Favorite tween features? Feature wish list?
FizixMan: When you create delegated methods, do they tend to be anything you would reuse, or are they usually too specific? Yesterday I needed to tween a ColorTransform, so I created a custom class to handle the behavior for me. Does this seem like the sort of thing that would be useful to you? Here is what a standard tween looks like: Code: Actuate.tween (MyObject, 1, { alpha: 1 } ); Here is what my color tween looks like: Code: Actuate.tween (MyObject, 1, { color: 0xFF0000 }, null, ColorTransformActuator); This is what my custom class looks like: Code: package com.eclecticdesignstudio.motion { import flash.display.DisplayObject; import flash.geom.ColorTransform; /** * @author Joshua Granick * @version 1.0 */ public class ColorTransformActuator extends SimpleActuator { public var blueOffset:Number; public var greenOffset:Number; public var redOffset:Number; private var colorTransform:ColorTransform; private var tweenTarget:DisplayObject; public function ColorTransformActuator (target:Object, duration:Number, properties:Object, tweenProperties:Object) { super (target, duration, properties, tweenProperties); colorTransform = new ColorTransform (); tweenTarget = target as DisplayObject; this.target = this; } public override function apply ():void { if ("color" in properties) { colorTransform.color = properties.color; tweenTarget.transform.colorTransform = colorTransform; } } public override function move ():void { super.move (); if ("color" in properties) { colorTransform = tweenTarget.transform.colorTransform; redOffset = colorTransform.redOffset; greenOffset = colorTransform.greenOffset; blueOffset = colorTransform.blueOffset; colorTransform.color = properties.color; delete properties.color; properties.redOffset = colorTransform.redOffset; properties.greenOffset = colorTransform.greenOffset; properties.blueOffset = colorTransform.blueOffset; } } public override function update (elapsedTime:Number):void { super.update (elapsedTime); colorTransform.redOffset = redOffset; colorTransform.greenOffset = greenOffset; colorTransform.blueOffset = blueOffset; tweenTarget.transform.colorTransform = colorTransform; } }
}
|
| Mon Oct 26, 2009 8:54 pm |
|
 |
|
FizixMan
Member
Joined: Thu Jul 26, 2007 7:06 pm Posts: 215 Location: Toronto, Ontario, Canada
|
 Re: Poll: Favorite tween features? Feature wish list?
My delegated methods are case-specific. I have a generic "Animation" class which takes the object scope and the method to invoke: Code: new Animation(Delegate.Create(this, this.DrawHighlightPercentage), null, null, 0, 1, 0.25, true, true); In this case, I have it paint a highlight glow and shift up an icon. The easiest way for me to control my custom highlighting behaviour was to create a method to set its state (I know, I could have used a property too, but I don't like having complex behaviour in properties). The DrawHighlightPercentage takes a decimal percentage value between 0 and 1, and in this case takes 0.25 seconds. The other inputs are essentially wrappers to the existing mx.transitions.Tween class and I supply default values if null is passed. For the little bit I've seen of custom tweeners, they function the same as yours where you pass an object, or list of properties to change. If I were to switch to a custom tweener, it would be a necessity that I can pass in a function delegate to have invoked. Don't let that influence your development though; I imagine our usage of tweens is the minority.
|
| Mon Oct 26, 2009 10:33 pm |
|
 |
|
CourseVector
Member
Joined: Mon Jan 21, 2008 6:58 pm Posts: 45
|
 Re: Poll: Favorite tween features? Feature wish list?
FizixMan, what would be the use-case for requiring a delegated method? If you're trying to tween a custom object I don't see why you don't use a tween class like tweenlite, pass in the object and just call a function on update. Although i'm pretty sure i'm completely off on my understanding of what you're doing though.
|
| Tue Oct 27, 2009 9:32 pm |
|
 |
|
elyon
Member
Joined: Wed Aug 01, 2007 3:37 pm Posts: 1220 Location: Grizzly Flats, CA
|
 Re: Poll: Favorite tween features? Feature wish list?
I think the point is that FizixMan wants to tween a function rather than a property, and he would prefer not to create a getter/setter.
In order to use an update handler, I think you would have to create a separate variable, tween that variable, then call your function as the tween updates so that you can pass in that value. Am I right on this?
|
| Tue Oct 27, 2009 9:58 pm |
|
 |
|
FizixMan
Member
Joined: Thu Jul 26, 2007 7:06 pm Posts: 215 Location: Toronto, Ontario, Canada
|
 Re: Poll: Favorite tween features? Feature wish list?
One "use-case" scenario, for example, involves applying a glow filter by altering its strength and alpha values. Since with Flash (or at least, ActionScript 2) you must alter the filter object then re-assign the .filters array for the MovieClip, it cannot be achieved by simply setting a field value. Furthermore, the tween animations are typically a combination of values, and I may even be doing other logic or checks inbetween. This could be accomplished by placing the logic in a property setter, but I feel that's a bit too much of a hack (it really isn't, but I prefer reserving properties for wrapping fields with possibly some minor logic to format/validate values). Ultimately CourseVector, yes, I could create a temporary, throw-away object, tween that custom object, set a listener to the tween's onUpdate/Change call, make sure scope is passed correctly, and invoke my custom method. But that's a lot of work, wouldn't you say? I'd rather have all that nicely wrapped up for me. You're right elyon, my tween wrappers do what you suggest, creating a temporary object and invoking the delegate with the onUpdate event. I don't know if it's necessarily the most efficient way, but so far the use of them in my company is purely for user interface animations so there's no performance bottleneck. I also have the class able to pass constants as additional parameters to the invoked method. So I might have something like: Code: new Animation(Delegate.Create(this, this.Draw), [targetObject, 0xFF0000], null, 0, 1, 0.25, true, true);
private function Draw(percentage:Number, target:MovieClip, baseColour:Number):Void { //some logic to draw }
|
| Wed Oct 28, 2009 5:11 am |
|
 |
|
elyon
Member
Joined: Wed Aug 01, 2007 3:37 pm Posts: 1220 Location: Grizzly Flats, CA
|
 Re: Poll: Favorite tween features? Feature wish list?
I can definitely see what you are saying. I think that it makes sense to encapsulate common tasks, like my color transform example, but if it gets too specific it can definitely get strange. I'll think I'll probably spend a little more time playing with filters sometime here, because it would be nice to be able to do something like this: Code: Actuate.tween (MyMovieClip, 1, { blurOffsetX: 10, blurOffsetY: 2, blurX: 10, blurY: 2 }, null, FilterActuator)
|
| Wed Oct 28, 2009 5:21 am |
|
 |
|
elyon
Member
Joined: Wed Aug 01, 2007 3:37 pm Posts: 1220 Location: Grizzly Flats, CA
|
 Re: Poll: Favorite tween features? Feature wish list?
I decided to go ahead and build it. Here's an example shape: Code: var Example:Sprite = new Sprite (); Example.graphics.beginFill (0xFF0000); Example.graphics.drawRect (0, 0, 100, 100); Example.filters = [ new DropShadowFilter () ]; addChild (Example); Then here's an example of how to tween the filter: Code: Actuate.tween (Example, 10, { filter: 0, blurX: 40, blurY: 40, strength: 300 }, null, FilterActuator); "filter" corresponds to the index of the filter you want to tween. If you only have one filter on your object, this will always be zero, but this offers flexibility if you have more than one filter in place. http://eclecticdesignstudio.com/code/ac ... %201.0.zip
|
| Wed Oct 28, 2009 6:27 am |
|
 |
|
Kulkoff
Member
Joined: Sat Nov 15, 2008 4:00 am Posts: 171
|
 Re: Poll: Favorite tween features? Feature wish list?
elyon, I realy like your tween library... Woold be great if Actuate can remove a custom twwen ( not all like reset() ). For example in TweenLite/Max it killTweensOf(target:Object, complete:Boolean = false):void Kills all the tweens of a particular object, optionally completing them first. and killVars(vars:Object, permanent:Boolean = true):Boolean Allows particular properties of the tween to be killed. And when you update svn on GoogleCode? Thanks for your work. Sorry for my "runglish" 
|
| Wed Oct 28, 2009 8:26 am |
|
 |
|
FizixMan
Member
Joined: Thu Jul 26, 2007 7:06 pm Posts: 215 Location: Toronto, Ontario, Canada
|
 Re: Poll: Favorite tween features? Feature wish list?
Nice job elyon!
Have you considered creating an interface/class to pass in the object properties to have it strongly typed? Or is it kept this way for maximum performance?
|
| Wed Oct 28, 2009 12:04 pm |
|
 |
|
CourseVector
Member
Joined: Mon Jan 21, 2008 6:58 pm Posts: 45
|
 Re: Poll: Favorite tween features? Feature wish list?
I think I understand how and why you use it. Although I just thought of a simpler way to do it. Just create a custom property on your object, and in that property take the actions you would normally take in your delegated function since the property would just be accepting a value from 0-1. But I think it was said before that you were avoiding making a getter/setter so not sure if that really helps.
But it would be interesting to have the ability to tween a function built in, never really thought about it before. I guess I've never run into the need for it.
|
| Wed Oct 28, 2009 12:22 pm |
|
 |
|
FizixMan
Member
Joined: Thu Jul 26, 2007 7:06 pm Posts: 215 Location: Toronto, Ontario, Canada
|
 Re: Poll: Favorite tween features? Feature wish list?
Yeah, we went over the possibility of using the property (in fact, that's what I used to use before I created a wrapper for the Tween class specifically to fire functions) but I did not like that method of implementation; it felt inelegant.
|
| Wed Oct 28, 2009 1:56 pm |
|
 |
|
elyon
Member
Joined: Wed Aug 01, 2007 3:37 pm Posts: 1220 Location: Grizzly Flats, CA
|
 Re: Poll: Favorite tween features? Feature wish list?
Kulkoff: Hey Kulkoff, I'm sorry if it isn't more clear. The method you are looking for is Actuate.stop With pause and resume, Actuate will pause and resume everything if you don't pass in any parameters. I used to have stop designed this way until I ran into a little problem: If the object you want to stop evaluates to "null" for some reason, like you haven't initialized it or it was recently deleted, Actuate was stopping everything ... definitely not what you want it to do. I decided to put the "stop all" functionality into Actuate.reset so it wouldn't happen by accident, and so I could tie-in any other cleaning up I need to wipe everything. I updated the stop method last night so that it will accept arrays as well as objects. These are all valid ways of stopping tweens: Code: Actuate.stop (MyClip); // stops all tweens for MyClip Actuate.stop (MyClip, { alpha: null }); // stops all alpha tweens for MyClip Actuate.stop (MyClip, [ "alpha" ]); // stops all alpha tweens for MyClip FizixMan: Last night I decided to create a "TweenProperties" object which contains all of the possible tween properties you can use, like ease, delay or onComplete. Is this like what you are talking about?
|
| Wed Oct 28, 2009 3:21 pm |
|
|
Who is online |
Users browsing this forum: No registered users and 0 guests |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum
|
|
 |