Jump to content
Search Community

Need a class for tweening Color Objects in AS2 <= F7

Kaleb242 test
Moderator Tag

Recommended Posts

Hey Jack, don't know if this exists, but I ran into a snag trying to use the ColorTransform plugin and ColorMatrix plugin in the AS2 version of TweenLite / TweenMax for a banner project with the ridiculous requirement of Flash 7 AS 2.0 and 30k file size, (yeah that's right, Flash 7, I was equally shocked) so the AS2 ColorTransform plugin and ColorMatrix plugin don't work since Flash 7 lacks flash.filters.BitmapFilter, which is what supplies the guts for those two plugins.

 

In order to tween a Color Transform on a MovieClip pre-Flash 8 / pre-BitmapFilter, I think I'd need an "endObject" plugin similar to the "endArray" plugin to tween between two objects holding Color Transform values and apply them over time with onUpdate and onUpdateParams. I tried hacking together an onUpdate:applyColorTransform method that cycled through properties of one object to another object used for animating the values, but had trouble with it...

 

AS 2.0 Flash 7 and below requires the use of Color() and use of the old setTransform() and getTransform() methods on that "Color"...

 

It would be nice if I could just specify a color object to use for the start values, and an endObject to specify the end values, taking a very similar approach to the endArray plugin, but for objects that have the same name/value pairs like Color() objects have. For example...

 

var DEFAULT_TRANSFORM:Object = {ra:100, rb:0, ga:100, gb:0, ba:100, bb:0, aa:100, ab:0};
var ROLLOVER_TRANSFORM:Object = {ra:100, rb:50, ga:100, gb:50, ba:100, bb:50, aa:100, ab:0};

var myObj:Object = DEFAULT_TRANSFORM;

var colorObj = new Color(targetClip);
colorObj.setTransform(DEFAULT_TRANSFORM);

TweenLite.to(myObj, 1, {endObject:ROLLOVER_TRANSFORM, onUpdate:applyColorTransform, onUpdateParams:[myObj]});

function applyColorTransform(obj:Object):Void {
colorObj.setTransform(obj);
}

 

Maybe there's a better way to go about it that I haven't thought of, but I think that kind of plugin would be handy and generic enough to have around... but maybe that's what TweenLite is already doing, looping through the matching properties of two objects and applying them to the target over the duration and easing type specified. My attempt wasn't looking so smooth, but maybe it was the lack of rounded props or my lack of sleep. ; )

Link to comment
Share on other sites

Did you try something like this?:

 

var color:Color = new Color(image_mc);
var transform:Object = color.getTransform();
TweenLite.to(transform, 1, {ra:100, rb:50, ga:100, gb:50, ba:100, bb:50, aa:100, ab:0, onUpdate:applyTransform, onUpdateParams:[color, transform]});
function applyTransform(c:Color, t:Object):Void {
c.setTransform(t);
}

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...