GreenSock


TweenFilterLite (AS2 Version) - Easily Tween Filters & Image Effects

Posted in Tweening by jack on the October 18th, 2007
Version 9.29, Updated 11/12/2008

Download Now
 
Donate

Join Club GreenSock to get bonus classes, updates, and much more

RECENT VERSION HIGHLIGHTS

  • TweenGroup - TweenGroup is a very powerful, flexible tool for managing groups of TweenLite/FilterLite/Max tweens. I believe it'll quickly become a must-have class for your tweening toolkit. TweenFilterLite is fully compatible with TweenGroup.
  • auto overwriting - You may never have to type "overwrite:false" again! Optionally use the new OverwriteManager class for advanced overwriting features. It costs about 1k and with one call to OverwriteManager.init(), all your tweens instantly get auto overwriting so that only overlapping properties in other tweens of the same object are overwritten. There are actually 4 options for overwriting now.
  • roundProps - Define individual properties that should be rounded to the nearest integer when tweening. This can be helpful for preventing non anti-aliased text or non-smoothed images from getting "fuzzy" when tweening position.
  • timeScale - Slow down or speed up a tween anytime. Half-speed would be 0.5, double-speed would be 2, etc.
  • globalTimeScale - Slow down or speed up ALL TweenMax and TweenFilterLite tweens anytime. Heck, you could even tween this value with TweenLite (which isn't affected by globalTimeScale) so that the change is gradual, like: TweenLite.to(TweenFilterLite, 1, {globalTimeScale:0.5});
  • _visible - To set a MovieClip's "_visible" property at the end of a tween, just use this special property, like TweenLite.to(my_mc, 2, {x:300, visible:false});
  • removeTint - Previously, to remove the tint from a MovieClip, you'd set tint:null, but the new way is to set removeTint:true.
  • CustomEase - Build your own custom easing equation with this interactive tool.

DESCRIPTION

TweenFilterLite extends the extremely lightweight (about 3k), powerful TweenLite class, adding the ability to tween filters (like blurs, glows, drop shadows, bevels, etc.) as well as advanced effects like contrast, colorization, brightness, saturation, hue, and threshold (combined size: 6k). The syntax is identical to the TweenLite class. If you're unfamiliar with TweenLite, I'd highly recommend checking it out. It provides easy way to tween multiple object properties over time including a MovieClip's position, alpha, volume, color, etc. Just like the TweenLite class, TweenFilterLite allows you to build in a delay, call any function when the tween starts or has completed (even passing any number of parameters you define), automatically kill other tweens that are affecting the same object (to avoid conflicts), tween numeric Arrays, etc. One of the big benefits of this class (and the reason "Lite" is in the name) is that it was carefully built to minimize file size. There are several other tweening engines out there, but in my experience, they required more than triple the file size which was unacceptable when dealing with strict file size requirements (like banner ads). I haven't been able to find a faster tween engine either with similar features. The syntax is simple and the class doesn't rely on complicated prototype alterations that can cause problems with certain compilers. TweenFilterLite is simple, very fast, and more lightweight (about 6k) than any other popular tweening engine.

And if you want even more features and don't mind a few extra kb, check out the new TweenMax class which adds bezier tweening, pause/resume, easier sequencing, and MUCH more. It can do everything TweenFilterLite does, plus more.

Other links: AS3 version | Forums | TweenGroup | CustomEase

FEATURE COMPARISON

  TweenLite TweenFilterLite TweenMax
File size
3k 6k 9k-11k
AS2 and AS3 versions with identical syntax
X X X
X X X
Tween ANY numeric property of any object
X X X
Tween multiple properties with a single line of code
X X X
Syncronized tweens
X X X
Use any standard easing equation
X X X
onComplete, onStart, and onUpdate callbacks, including the ability to pass any number of parameters to those functions (onCompleteParams, onStartParams, onUpdateParams)
X X X
Delay a tween's start time (good for sequencing)
X X X
Automatic garbage collection
X X X
Tween frames of a MovieClip
X X X
Tween tint of a MovieClip/DisplayObject
X X X
autoAlpha (toggles visibility of an object off when the alpha hits zero)
X X X
Tween the volume of any MovieClip/SoundChannel
X X X
Unique "from()" call that allows you to use the current properties as the end values
X X X
Use relative values
X X X
Tween Arrays of numeric values with a single call
X X X
Pass extra parameters to easing equations (like Elastic.easeOut or Back.easeOut) for added control
X X X
Call any function after a set amount of time with the delayedCall() method. Even pass any number of parameters to the function.
X X X
Round values to the nearest integer while tweening (NEW!)
  X X
Speed up or slow down a tween anytime with the timeScale property (NEW!)
  X X
Speed up or slow down ALL TweenMax and TweenFilterLite tweens anytime with the static globalTimeScale property. (NEW!)
  X X
Advanced management of overwriting (AUTO, NONE, ALL, or CONCURRENT) with OverwriteManager (NEW!)
optional optional X
Tween filters like Blur, Glow, DropShadow, Bevel, and ColorMatrix
  X X
Simple controls for tweening a MovieClip's/DisplayObject's saturation, hue, brightness, contrast, threshold, and colorization
  X X
Bezier tweening
    X
Bezier "through" tweening (define points to hit instead of just control points)
    X
Automatically orient an object's rotation to a Bezier path
    X
Pause/Resume capability
with
TweenGroup
with
TweenGroup
X
reverse() and/or restart() (NEW!)
with
TweenGroup
with
TweenGroup
X
Grouping and Sequencing (NEW!)
with
TweenGroup
with
TweenGroup
with
TweenGroup
Tween multiple objects with a single call, including a special "stagger" property that staggers the starting time of each tween
with
TweenGroup
with
TweenGroup
with
TweenGroup
yoyo (NEW!)
with
TweenGroup
with
TweenGroup
X
loop (NEW!)
with
TweenGroup
with
TweenGroup
X
shortRotation (NEW!) - automatically rotates in the shortest direction
    X
Change destination values anytime with setDestination()(NEW!)
    X
killProperties() - selectively kill properties of a particular tween (NEW!)
    X
Jump to any point in the tween using the "progress" property
    X
Tween unlimited hex color properties
    X
AS3 Event listeners (NEW!)
    X
isTweening() function for easily determining if an object is currently tweening
    X
Get an Array of all TweenMax (and TweenLite and TweenFilterLite) instances that are currently affecting a particular target object.
    X
Price:
FREE (supported by donations)

USAGE

Every call to TweenFilterLite.to() or TweenFilterLite.from() returns a TweenFilterLite instance which you can optionally keep track of in order to have more control. Here are a few examples of how to create instances:

  1. import gs.*;
  2. TweenFilterLite.to(mc, 1, {_x:200}); //automatically garbage collects
  3. var myTween:TweenFilterLite = TweenFilterLite.to(mc, 1, {_x:200}); //stores a reference to the TweenFilterLite instance, but you're responsible for making sure it becomes eligible for garbage collection when you're finished with it (you can simply set your variable to null, or if it is still in progress, call TweenFilterLite.removeTween(myTween) first)
  4. var myTween:TweenFilterLite = new TweenFilterLite(mc, 1, {_x:200}); //identical to the previous line - it just looks more object-oriented.

Each TweenFilterLite instance has the following properties:

  • target : Object (changing target after the tween begins has no effect on the tween)
  • duration : Number
  • timeScale : Number - Multiplier for controlling the speed of the tween. 0.5 = half speed, 1 = normal speed, 2 = double speed, etc. (This value is combined with the globalTimeScale to give you lots of control)

INSTANCE METHODS

TweenFilterLite(target:Object, duration:Number, variables:Object):TweenFilterLite
  • Description: Constructor. Property values are tweened from whatever they are at the time the tween begins to whatever you define in the variables parameter. (unless you use "runBackwards:true" which is the same as using TweenFilterLite.from())
  • Parameters:
    1. target : Object - Target object whose properties we're tweening
    2. duration : Number - Duration (in seconds) of the tween
    3. variables : Object - An object containing the end values of all the properties you'd like to have tweened (or if you're using the TweenFilterLite.from() method, these variables would define the BEGINNING values). Pass in one object for each filter (named appropriately, like blurFilter, glowFilter, colorMatrixFilter, etc.) Filter objects can contain any number of properties specific to that filter, like blurX, blurY, contrast, color, distance, colorize, brightness, highlightAlpha, etc.
      Special Properties:

      • delay : Number - The number of seconds you'd like to delay before the tween begins. This is very useful when sequencing tweens
      • ease : Function - You can specify a function to use for the easing with this variable. For example, gs.easing.Elastic.easeOut. The Default is Regular.easeOut. To build a custom ease, check out the GreenSock CustomEase Builder tool.
      • easeParams : Array - An Array of extra parameter values to feed the easing equation. This can be useful when you use an equation like Elastic and want to control extra parameters like the amplitude and period. Most easing equations, however, don't require extra parameters so you won't need to pass in any easeParams.
      • autoAlpha : Number - Use it instead of the _alpha property to gain the additional feature of toggling the _visible property to false when _alpha reaches 0. It will also toggle _visible to true before the tween starts if the value of autoAlpha is greater than zero.
      • visible : Boolean - To set a MovieClip's "_visible" property at the end of the tween, use this special property.
      • volume : Number - Tweens the volume of any MovieClip
      • tint : Number - To change a MovieClip's tint, set this to the hex value of the color you'd like the MovieClip to end up at (or begin at if you're using TweenLite.from()). An example hex value would be 0xFF0000.
      • removeTint : Boolean - If you'd like to remove the tint that's applied to a MovieClip, pass true for this special property.
      • frame : Number - Use this to tween a MovieClip to a particular frame.
      • timeScale : Number - Multiplier for controlling the speed of the tween. 0.5 = half speed, 1 = normal speed, 2 = double speed, etc. (hint: if you want to gradually speed up or slow down a tween, you could get fancy and use another tween to tween the timeScale propety!) NOTE: There is also a static TweenMax.globalTimeScale property that affects ALL TweenMax and TweenFilterLite tweens (not TweenLite though)
      • roundProps : Array - If you'd like the inbetween values in a tween to always get rounded to the nearest integer, use the roundProps special property. Just pass in an Array containing the property names that you'd like rounded. For example, if you're tweening the _x, _y, and _alpha properties of mc and you want to round the _x and _y values (not _alpha) every time the tween is rendered, you'd do: TweenFilterLite.to(mc, 2, {_x:300, _y:200, _alpha:0.5, roundProps:["_x","_y"]});
      • onStart : Function - If you'd like to call a function as soon as the tween begins, pass in a reference to it here. This can be useful when there's a delay and you want something to happen just as the tween begins.
      • onStartParams : Array - An array of parameters to pass the onStart function.
      • onStartScope : Object - Use this to define the scope of the onStart function.
      • onUpdate : Function - If you'd like to call a function every time the property values are updated (on every frame during the time the tween is active), pass a reference to it here.
      • onUpdateParams : Array - An array of parameters to pass the onUpdate function (this is optional)
      • onUpdateScope : Object - Use this to define the scope of the onUpdate function.
      • onComplete : Function - If you'd like to call a function when the tween has finished, use this.
      • onCompleteParams : Array - An array of parameters to pass the onComplete function (this is optional)
      • onCompleteScope : Object - Use this to define the scope of the onComplete function.
      • persist : Boolean - if true, the TweenFilterLite instance will NOT automatically be removed from the rendering queue and made eligible for garbage collector when it is complete. However, it is still eligible to be overwritten by new tweens even if persist is true. By default, it is false.
      • renderOnStart : Boolean - If you're using TweenFilterLite.from() (or runBackwards:true) with a delay and want to prevent the tween from rendering until it actually begins, set this special property to true. By default, it's false which causes TweenFilterLite.from() to render its values immediately, even before the delay has expired.
      • runBackwards : Boolean - Flips the start and end values in a tween. The from() method automatically sets this value to true.
      • overwrite : Number - Controls how other tweens of the same object are handled when this tween is created. You can set a default value to be used with ALL tweens in your SWF using the OverwriteManager's init() method, or control them individually with this overwrite property. Here are the options:
        1. 0 (NONE): No tweens are overwritten. This is the fastest mode, but you need to be careful not to create any
          tweens with overlapping properties, otherwise they'll conflict with each other.
        2. 1 (ALL): (this is the default unless OverwriteManager.init() has been called) All tweens of the same object are completely overwritten immediately when the tween is created.
          TweenFilterLite.to(mc, 1, {x:100, y:200});
          TweenFilterLite.to(mc, 1, {_x:300, delay:2, overwrite:1}); //immediately overwrites the previous tween
        3. 2 (AUTO): (used by default if OverwriteManager.init() has been called) Searches for and overwrites only individual overlapping properties in tweens that are active when the tween begins.
          TweenFilterLite.to(mc, 1, {_x:100, _y:200});
          TweenFilterLite.to(mc, 1, {_x:300, overwrite:2}); //only overwrites the "_x" property in the previous tween
        4. 3 (CONCURRENT): Overwrites all tweens of the same object that are active when the tween begins.
          TweenFilterLite.to(mc, 1, {_x:100, y:200});
          TweenFilterLite.to(mc, 1, {_x:300, delay:2, overwrite:3}); //does NOT overwrite the previous tween because the first tween will have finished by the time this one begins.
      • blurFilter : Object - To apply a BlurFilter, pass an object with one or more of the following properties:
        • blurX
        • blurY
        • quality
      • glowFilter : Object - To apply a GlowFilter, pass an object with one or more of the following properties:
        • alpha
        • blurX
        • blurY
        • color
        • strength
        • quality
        • inner
        • knockout
      • colorMatrixFilter : Object - To apply a ColorMatrixFilter, pass an object with one or more of the following properties:
        • colorize
        • amount
        • contrast
        • brightness
        • saturation
        • hue
        • threshold
        • relative
        • matrix
      • dropShadowFilter : Object - To apply a DropShadowFilter, pass an object with one or more of the following properties:
        • alpha
        • angle
        • blurX
        • blurY
        • color
        • distance
        • strength
        • quality
      • bevelFilter : Object - To apply a BevelFilter, pass an object with one or more of the following properties:
        • angle
        • blurX
        • blurY
        • distance
        • highlightAlpha
        • highlightColor
        • shadowAlpha
        • shadowColor
        • strength
        • quality

STATIC METHODS

TweenFilterLite.to(target:Object, duration:Number, variables:Object):TweenFilterLite
  • Description:Creates a new TweenFilterLite instance for you, but shields you from having to create a variable to store it in which can make garbage collection more difficult.
    1. var myTween:TweenFilterLite = new TweenFilterLite(mc, 1, {_x:300});
    2. TweenFilterLite.to(mc, 1, {_x:300}); //exactly the same as the previous line, but handles garbage collection automatically.

  • Parameters: Same as Constructor (see above)
TweenFilterLite.from(target:Object, duration:Number, variables:Object):TweenFilterLite
  • Description: Exactly the same as TweenFilterLite.to(), but instead of tweening the properties from where they're at currently to whatever you define, this tweens them the opposite way - from where you define TO where ever they are now (when the method is called). This is handy for when things are set up on the stage the way the should end up and you just want to tween them to where they are.
  • Parameters: Same as TweenFilterLite.to(). (see above)
TweenFilterLite.delayedCall(delay:Number, onComplete:Function, onCompleteParams:Array, scope:Object):TweenLite
  • Description: Provides an easy way to call any function after a specified number of seconds. Any number of parameters can be passed to that function when it's called too.
  • Parameters:
    1. delay : Number - Number of seconds before the function should be called.
    2. onComplete : Function - The function to call
    3. onCompleteParams : Array - [optional] An array of parameters to pass the onComplete function when it's called.
    4. scope : Object - [optional] Defines the scope of the function.
TweenFilterLite.killTweensOf(target:Object, complete:Boolean):Void
  • Description: Provides an easy way to kill all tweens of a particular Object/MovieClip. You can optionally force it to immediately complete (which will also call the onComplete function if you defined one)
  • Parameters:
    1. target : Object - Any/All tweens of this Object will be killed.
    2. complete : Function - If true, the tweens for this object will immediately complete (go to the ending values and call the onComplete function if you defined one).
TweenFilterLite.killDelayedCallsTo(function:Function):Void
  • Description: Provides an easy way to kill all delayed calls to a particular function (ones that were instantiated using the TweenFilterLite.delayedCall() method).
  • Parameters:
    1. function : Function - Any/All delayed calls to this function will be killed.
TweenFilterLite.setGlobalTimeScale(scale:Number):void
  • Description: Speed up or slow down ALL TweenMax and TweenFilterLite tweens. Each tween's timeScale property and the TweenFilterLite.globalTimeScale are cumulative, giving you lots of control. So, for example, if an individual tween has a timeScale of 0.5 and you set the globalTimeScale to 0.5 as well, the tween will appear to run at 0.25 speed. If you want the globalTimeScale to gradually change, you can even tween it using TweenLite (which isn't affected by globalTimeScale), like this: TweenLite.to(TweenFilterLite, 1, {globalTimeScale:0.5});
  • Parameters:
    1. scale : Number - Multiplier for controlling the speed of the tweens. 0.5 = half speed, 1 = normal speed, 2 = double speed, etc.

EXAMPLES

As a simple example, you could tween the blur of clip_mc from where it's at now to 20 over the course of 1.5 seconds by:

  1. import gs.TweenFilterLite;
  2. TweenFilterLite.to(clip_mc, 1.5, {blurFilter:{blurX:20, blurY:20}});

If you want to get more advanced and tween the clip_mc MovieClip over 5 seconds, changing the saturation to 0, delay starting the whole tween by 2 seconds, and then call a function named "onFinishTween" when it has completed and pass in a few arguments to that function (a value of 5 and a reference to the clip_mc), you'd do so like:

  1. import gs.*;
  2. import gs.easing.*;
  3. TweenFilterLite.to(clip_mc, 5, {colorMatrixFilter:{saturation:0}, delay:2, onComplete:onFinishTween, onCompleteParams:[5, clip_mc]});
  4. function onFinishTween(argument1:Number, argument2:MovieClip):Void {
  5.     trace("The tween has finished! argument1 = " + argument1 + ", and argument2 = " + argument2);
  6. }

If you have a MovieClip on the stage that already has the properties you'd like to end at, and you'd like to start with a colorized version (red: 0xFF0000) and tween to the current properties, you could:

  1. import gs.*;
  2. TweenFilterLite.from(clip_mc, 5, {colorMatrixFilter:{colorize:0xFF0000}});

FAQ

  1. How do I install the class? Do I have to import it on every frame?
    Just make sure the "gs" folder from the download is in the same folder as your FLA file. Keep the class files in the "gs" folder (don't remove them). That's it. And, yes, just like any Class, you need to import TweenFilterLite at the top of any frame that contains code referencing it. This does NOT add extra Kb to your file size very time you import it. Flash is smart enough to embed it once and all the other import statements just act as a "pointer" to the embedded Class.
  2. Why doesn't the tweening engine selectively overwrite ONLY tweens that are affecting the same property? How can I achieve this effect?
    By default, when you create a tween, TweenLite looks for all tweens of the same object that already exist and kills them immediately. However, you can add advanced management of overwriting (including AUTO overwriting of only overlapping properties) using the OverwriteManager class.
  3. Can I set up a sequence of tweens so that they occur one after the other?
    Of course! Just use the delay property and make sure you set the overwrite property to false (otherwise tweens of the same object will always overwrite each other to avoid conflicts). Here's an example where we colorize a MovieClip red over the course of 2 seconds, and then blur it over the course of 1 second:

    1. import gs.*;
    2. TweenFilterLite.to(clip_mc, 2, {colorMatrixFilter:{colorize:0xFF0000, amount:1}});
    3. TweenFilterLite.to(clip_mc, 1, {blurFilter:{blurX:20, blurY:20}, delay:2, overwrite:0});

  4. Why aren't my filters working?
    If you're using a filter that has an alpha property, try setting it to 1. The default alpha value is zero, so the filter may be working just fine, but you're not seeing it.
  5. Do the properties have to be in a specific order?
    Nope. The only thing that matters is that the first parameter is the object you're tweening, the second parameter is the time (in seconds), and the third parameter contains all the properties you want to tween (in any order). So TweenFilterLite.to(clip_mc, 1, {colorMatrixFilter:{colorize:0xFF0000, amount:1}}) is the same as TweenFilterLite.to(clip_mc, 1, {colorMatrixFilter:{amount:1, colorize:0xFF0000}});
  6. Can I use TweenFilterLite to tween things other than filters?
    Sure. It extends TweenLite, so you can tween any property you want. TweenFilterLite.to(my_mc, 1, {_x:200}) gives you the same result as TweenLite.to(my_mc, 1, {_x:200}). However, I'd recommend using TweenLite to tween properties other than filters because in order to accommodate the specialized nature of filters, TweenFilterLite's code is a bit lengthier which translates into more work for the processor. It's doubtful that anyone would notice a performance hit unless you're tweening hundreds or thousands of instances simultaneously, but I'm a bit of an efficiency freak.
  7. Why are TweenLite and TweenFilterLite and TweenMax split into 3 classes instead of building all the functionality into one class?
    1. File size. Only a portion of projects out there require tweening of filters, beziers, hex colors, etc. TweenLite is 3k whereas TweenFilterLite is 6k and TweenMax is about 9k. Again, one of the stated purposes of TweenLite is to minimize file size & code bloat. If someone only wants to use TweenFilterLite or TweenMax, great. But I think many people appreciate being able to use the most lightweight option for their needs and shave off the 3k when possible.
    2. Speed. Tweening filters is a more complex task. There are additional if/else statements and calculations in the rendering loop inside TweenFilterLite which could potentially slow things down a bit, even for non-filter tweens (I doubt anyone would notice a difference unless they're running hundreds or thousands of simultaneous tweens, but I'm a big fan of keeping things as efficient & fast as possible)
  8. Do I have to purchase a license to use this code? Can I use it for commercial purposes?
    If you use it in a commercial project, I'd strongly encourage you to at least join Club GreenSock which gets you some bonus classes (only available to club members), update notifications, and more. Your donations keep this project going. However, donations are not mandatory. TweenFilterLite is free for virtually all uses including commercial projects. The only exception is inclusion in commercial products for which you sell licenses to end users. If you don't charge licensing fees for your product, you don't get charged a licensing fee for TweenFilterLite. If you do license your product to end users and would like to use my code, please e-mail me at info@greensock.com and we can determine a reasonable licensing fee. Don't hesitate to inquire or assume the licensing fee would be too much - you may be surprised. Many large companies as well as single developers have obtained licenses because in their view, it ultimately saved them time and gave them a better, more reliable end product.

Need Help?

Feel free to post your question on the forums. You'll increase your chances of getting a prompt answer if you include a simplified FLA file (and any class files) that clearly demonstrates the problem and provide a brief explanation.

Author: Jack Doyle, (e-mail: jack -at- greensock.com)
Copyright 2008, GreenSock (This work is subject to the terms here.)

To download the code, you must agree to the following license:

Copyright 2008, GreenSock, Inc.

"NO CHARGE" NON-EXCLUSIVE SOFTWARE LICENSE AGREEMENT

-----------------------------------------------------------------------------
PLAIN ENGLISH SUMMARY:

  1. You may use the code at no charge in web sites, games, components, applications, and other software as long as end users are not charged a fee of any kind to use your product or gain access to it. It doesn’t matter if you are paid to create the site/product. If you charge end users a fee, you must sign up for a corporate Club GreenSock membership which comes with a commercial license granting you permission to do so. See http://blog.greensock.com/club/ for details.
  2. Since the code is updated frequently and developers are best served by having the latest version, please avoid (or at least minimize) distributing the source code outside your organization.
  3. Use at your own risk. I offer no warranties.
  4. Please respect the copyright.

-----------------------------------------------------------------------------

LEGALESE:

This is a legal agreement between you (either an individual or a single entity) and GreenSock, Inc. ("GREENSOCK") for the proprietary GreenSock ActionScript code known as TweenLite, TweenFilterLite, TweenMax, TweenGroup, OverwriteManager, and other code that is freely available for download at http://blog.greensock.com or http://www.greensock.com (this code and documentation, as well as any updates which may at GREENSOCK's sole discretion be provided to you from time to time, are referred to in this Agreement as "PROGRAM") By installing, copying, or otherwise using the PROGRAM, you agree to the terms and conditions of this Agreement. If you do not agree to the terms and conditions of this Agreement, please do not install or use the PROGRAM.

I. LICENSE
A. Subject to the terms and conditions of this Agreement, GREENSOCK hereby grants you a non-exclusive, worldwide, non-transferable right to use the PROGRAM in web sites, games, applications, components and other software for which the end user is NOT charged any fees. If you would like to use the code in a commercially licensed software product for which end users are charged a fee (either for usage or access), simply sign up for a corporate Club GreenSock membership at http://blog.greensock.com/club/.

II. LIMITATION OF LICENSE AND RESTRICTIONS
A. You agree that you will not disclose, sell, rent, license, or otherwise distribute the PROGRAM's source code or any derivative works thereof to any third party without the prior written consent of GREENSOCK. Derivative works are defined as modifications that add substantive functionality to the PROGRAM and do not include bug fixes or other minor modifications required to operate the PROGRAM as originally intended. Limited distribution of the source code to vendors as part of your Work Product is acceptable so long as they agree to the terms of this Agreement. You agree not to modify or delete GreenSock's existing copyright notice located in the source code.

B. You may use, duplicate, and distribute the compiled object code solely as embedded in a Work Product created by you, either for your own use or for distribution to a third party so long as end users of the Work Product are not charged a fee for usage. Please see http://blog.greensock.com/licensing/ for descriptions of Work Products that qualify for the "No Charge" license.

III. CONSIDERATION
A. The license rights granted to you under this Agreement are at no charge, but only in the following circumstances: If, either on your own behalf or on behalf of a third party, you incorporate the Software into a web site, software application, program or any component thereof (collectively, “Work Product”), which in the case of a web site, must be accessible to internet users without payment of a fee of any kind by a user, and in the case of a software application, program or component, neither you nor anyone to whom you distribute the Work Product charges a user a fee of any kind to use such Work Product or application, program or component into which such Work Product is embedded. The foregoing shall apply regardless of whether you are paid to create such Work Product and, under any circumstances, shall be subject to the prohibition against distribution of Source Code set forth in Section II.

B. In the event your intended use of the Software does not meet the criteria for the “no charge” license rights set forth in the immediately preceding paragraph, then you are not licensed to use the PROGRAM under this Agreement and must license the PROGRAM under GreenSock’s separate fee-based Software License Agreement which is granted to corporate Club GreenSock members (see http://blog.greensock.com/club/ for details).

IV. TITLE AND OWNERSHIP
A. The PROGRAM is licensed, not sold, and is protected by copyright laws and international treaty provisions. You acknowledge that no title to the intellectual property in the Software is transferred to you. You further acknowledge that title and full ownership rights to the PROGRAM, including all intellectual property rights therein, will remain the exclusive property of GreenSock and you will not acquire any rights to the PROGRAM except as expressly set forth in this Agreement. You agree that any copies of the PROGRAM you make will contain the same proprietary notices which appear on and in the PROGRAM.

V. DISCLAIMER OF WARRANTY AND LIMITATION OF LIABILITY
A. THE PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. GREENSOCK DOES NOT WARRANT THAT THE FUNCTIONS CONTAINED IN THE PROGRAM WILL MEET YOUR REQUIREMENTS OR THAT OPERATION WILL BE UNINTERRUPTED OR ERROR FREE. GREENSOCK shall not be liable for special, indirect, incidental, or consequential damages with respect to any claim on account of or arising from this Agreement or use of the PROGRAM, even if GREENSOCK has been or is hereafter advised of the possibility of such damages. Because some states do not allow certain exclusions or limitations on implied warranties or of liability for consequential or incidental damages, the above exclusions may not apply to you. In no event, however, will GREENSOCK be liable to you, under any theory of recovery, in an amount in excess of the license fee paid by you under this Agreement. Notwithstanding anything else in this agreement, you agree to indemnify GREENSOCK, its assignees, and licensees, and hold each of them harmless from and against any and all claims, demands, losses, damages, liabilities, costs, and expenses, including legal fees.

B. GREENSOCK may, at its sole discretion, provide support services related to the PROGRAM, but has no obligation to do so.

VI. TERMINATION
GreenSock may terminate this Agreement at any time if you fail to comply with the terms and conditions of this Agreement.

VII. MISCELLANEOUS
A. This Agreement shall be construed in accordance with the laws of the State of Illinois. Should you for any reason bring a claim, demand, or other action against GREENSOCK, its agents or employees, arising out of this Agreement or the PROGRAM licensed herein, you agree to bring said claim only in the Illinois Court of Claims.

B. THIS AGREEMENT REPRESENTS THE COMPLETE AND EXCLUSIVE STATEMENT OF THE AGREEMENT BETWEEN GREENSOCK AND YOU AND SUPERSEDES ALL PRIOR AGREEMENTS, PROPOSALS, REPRESENTATIONS AND OTHER COMMUNICATIONS, VERBAL OR WRITTEN, BETWEEN THEM WITH RESPECT TO USE OF THE PROGRAM. THIS AGREEMENT MAY BE MODIFIED ONLY WITH THE MUTUAL WRITTEN APPROVAL OF AUTHORIZED REPRESENTATIVES OF THE PARTIES.

C. The terms and conditions of this Agreement shall prevail notwithstanding any different, conflicting, or additional terms or conditions which may appear in any purchase order or other document submitted by you. You agree that such additional or inconsistent terms are deemed rejected by GREENSOCK.

D. GREENSOCK and you agree that any xerographically or electronically reproduced copy of this Agreement shall have the same legal force and effect as any copy bearing original signatures of the parties.

I'd like to donate & get bonus classes, update notifications, SVN access, and more.

16 Responses to 'TweenFilterLite (AS2 Version) - Easily Tween Filters & Image Effects'

Subscribe to comments with RSS or TrackBack to 'TweenFilterLite (AS2 Version) - Easily Tween Filters & Image Effects'.


  1. on May 26th, 2007 at 3:44 am

    Jack,

    I can only say that I wish you designed and developed vehicles, were in charge of the deficit, and ran an organically based fast food restaurant chain. Because if you did, by now, we would all be flying around in our government issued hover cars that ran on raw sewage and emitted nothing but water vapor while consuming conveniently prepared, organic gourmet meals, which contributed to each of us becoming the healthy, happy, active centurions God intended us to be.

    Yes, these classes are that idealistically good. Adobe(Macromedia) should give you millions. I wish that I could, but perhaps a pittance of 10$ will help set a precedence.

    This new class seems every bit as brilliant and compact as TweenLite (which I love). Can’t wait to start playing with it. Thank you, thank you, and thank you.


  2. on May 26th, 2007 at 3:47 am

    P.S.
    Make it easy for people to give you money. Put up a direct PayPal link . Genorosity and laziness aren’t mutually exclusive traits :)

  3. Dale Sattler said,

    on June 7th, 2007 at 4:39 pm

    Great class. I was about to write a function to do this and thought I’d give google a try. Excellent!

  4. Eagle said,

    on July 3rd, 2007 at 8:23 am

    Wow!!! You got my fully respect!! D@mn you know something! :D It’s working great!! The only thing I don’t know is how to apply a color and a shadow modify at once. Cool though!

  5. jack said,

    on July 3rd, 2007 at 8:53 am

    Actually, Eagle, it’s pretty simple to apply a colorize filter tween and also a drop shadow tween (or any filter) - just use two tweens and make sure the second one sets the overwrite property to false, like:

    TweenFilterLite.to(my_mc, 2, {colorMatrixFilter:{colorize:0xFF0000}});
    TweenFilterLite.to(my_mc, 2, {dropShadowFilter:{blurX:5, blurY:5, color:0×00FF00}, overwrite:false});


  6. on August 29th, 2007 at 10:09 am

    Flash Genius again! Lovely thanks,

    Dan C


  7. on September 3rd, 2007 at 1:20 pm

    I’ve been teaching myself as2 & as3, as well as everything else that goes with interactive design… and there’s just some things that take a bit more than understanding the logic to figure out. I’ve been trying to understand the blurs and other filters for DAYS. It’s highly pertinent to a website i’m strying to create. You sir, are a miracle man in my book. Every question I’ve had with this project, you answered in entirety with this one blog alone.

    You’re a life saver… more importantly so, a sanity saver ;)

    Thank you VERY much for taking the time with this,

    C. W. Calabrese

  8. ciumexan said,

    on October 26th, 2007 at 4:44 pm

    you are the man! i’ve been lookin for one of this classes for a long time ;)
    kudos
    keep up the good work dude!

  9. Alex said,

    on January 21st, 2008 at 7:59 am

    I have been using TweenLite for about a month now and all I can say is that your classes are absolutely brilliant! Thanks a lot!

    One thing I’m curious about is how you apply several filters at the same time to an object, lets say you want to move it while adding some glow and removing a drop shadow.

  10. jack said,

    on January 21st, 2008 at 8:41 am

    Alex, you should be able to do that without a problem - just remember that unless you set the “overwrite” property to false, TweenLite (and TweenFilterLite) will always overwrite existing tweens of the same object. So to move a MovieClip while adding a glow and removing a drop shadow, you could do something like:

    TweenFilterLite.to(my_mc, 2, {glowFilter:{color:0xFF0000, strength:2, blurX:10, blurY:10}, _x:100, _y:300});
    TweenFilterLite.to(my_mc, 2, {dropShadowFilter:{alpha:0}, overwrite:false});

  11. Michiel said,

    on January 23rd, 2008 at 10:17 am

    I can think of just two more major functions. One would be the ability to pause (all) tweens. This would be wildly useful in some cases. Right now I’m making a video banner which uses vector animations, but people are going to be pausing and playing the video.

    Another possibility would be the ability to tween through a timeline animation. I once made an animation of a sunrise which used several motion tweens; the entire animation timeline was then tweened from start to end in a certain time, using a standard quadratic equation. It looked great, and works really well if the animation is long enough (to provide enough frames for low-movement parts of the equation).

  12. jack said,

    on January 23rd, 2008 at 10:53 am

    Michiel, I have avoiding adding pause/resume functionality to TweenLite in order to keep file size way down, but TweenMax is now officially released and it includes that feature (and many more). Check it out at http://www.TweenMax.com

    Also, it’s very easy to do the frame tween you’re talking about. As of version 6, frame tweening is built into TweenLite!


  13. on February 24th, 2008 at 4:31 am

    dude.
    I’ve been tweening tings for years…I’ve been too complacent with the ol’ lmc_tween.as because you could write two tweens on the one movieclip without the first overwriting the second which I found no other tweener did…I just noticed you’re little snippet of code: overwrite:false in your tweener…You’re a F*&king legend!! I am a better deviner after visiting your website tonight.
    Radical

  14. heaversm said,

    on April 3rd, 2008 at 4:20 pm

    Hey - very cool! One question - is there an easy translation between the numbers you use for the color matrix and the numbers used in flash’s CS3’s built in filter tweener. I have some tweens I want to make to a color, and I have their exact values in flash (example: HUE: -63, SATURATION: 70) - but this doesn’t really translate over to Tweenfilter lite. How best to approximate those values? Nice work!

  15. jack said,

    on April 3rd, 2008 at 7:56 pm

    heaversm, here’s an easy way to match exactly what you created in the Flash CS3 (or Flash 8) authoring environment in terms of the ColorMatrixFilter. All you need to do is get the necessary values in the matrix array and pass it to the new version of TweenFilterLite (7.04). Here’s some code that grabs those values, traces them to your output window (in case you want to copy/paste), clears the filter, and tweens it back into place after a 1 second delay:

    import gs.*;
    import flash.filters.*;

    function getCurrentMatrix($mc:MovieClip):Array {
    var filters:Array = $mc.filters;
    for (var i:Number = 0; i < filters.length; i++) {
    if (filters[i] instanceof ColorMatrixFilter) {
    return filters[i].matrix;
    }
    }
    }

    var curMatrix:Array = getCurrentMatrix(mc);
    trace(”TweenFilterLite.to(mc, 3, {colorMatrixFilter:{matrix:[" + curMatrix + "]}})”);

    mc.filters = []; //clears filters;
    TweenFilterLite.to(mc, 3, {colorMatrixFilter:{matrix:curMatrix}, delay:1});

  16. the-enemy said,

    on July 9th, 2008 at 11:17 am

    Hey Jack,

    Thanks a bunch for TweenLite // TweenFilterLite. They’re both so easy to work with it’s saving me hours of work.

    Great Job! Keep it up!

    Regards,
    The Enemy.

Leave a Reply