Hey Flashcoders,

Has anyone here attempted to tween the Flash 8 ColorTransform class? I am having some strange issues while trying to tween some ColorTransform objects using Grant Skinner's MultiTween class. Seems that whenever I tween a ColorTransform object which contains yellow (?), I get a random spectrum of colors before the tween reaches it's target value. I've posted the source and have included the AS below. I realize there are other color-tweening scripts out there, but I was trying to use the ColorTransform class to see if it could be done.

Source:
http://download.danro.net/flashcoders/color_tween_test.zip

Thanks,
-Danro


code follows ----------------------

import com.gskinner.transitions.MultiTween;
import flash.geom.Transform;
import flash.geom.ColorTransform;
import mx.transitions.easing.*;
import mx.transitions.Tween;
import mx.utils.Delegate;

// color transform objects
var originColor:ColorTransform = new ColorTransform();
var currentColor:ColorTransform = new ColorTransform();
var rollOverColor:ColorTransform = new ColorTransform();
rollOverColor.rgb = 0xFFCC00;
var rollOutColor:ColorTransform = new ColorTransform();
rollOutColor.rgb = 0x0066CC;

// movieclip transform
var trans:Transform = new Transform(test_mc);

// update color function
function updateColor () {
        trans.colorTransform = currentColor;
        debug("DEBUG >> " + trans.colorTransform);
}

// set vars
var colorTween:Tween;
var mTween:MultiTween;

// rollover tween
function buttonRollOver () {
        mTween = new MultiTween(currentColor, rollOverColor);
        colorTween.stop();
        colorTween = new Tween(mTween, "position", Regular.easeOut, 0, 1, 20);
        colorTween.onMotionChanged = Delegate.create(this, updateColor);
        debug("DEBUG >> --------- roll over -----------");
}

// rollout tween
function buttonRollOut () {
        mTween = new MultiTween(currentColor, rollOutColor);
        colorTween.stop();
colorTween = new Tween(mTween, "position", Regular.easeInOut, 0, 1, 20);
        colorTween.onMotionChanged = Delegate.create(this, updateColor);
        colorTween.onMotionFinished = Delegate.create(this, reset);
        debug("DEBUG >> --------- roll out -----------");
}

// reset color to original
function reset () {
        mTween = new MultiTween(currentColor, originColor);
        colorTween.stop();
colorTween = new Tween(mTween, "position", Regular.easeInOut, 0, 1, 30);
        colorTween.onMotionChanged = Delegate.create(this, updateColor);
        debug("DEBUG >> --------- reset -----------");
}

// button events
test_mc.onRollOut = Delegate.create(this, buttonRollOut);
test_mc.onRollOver = Delegate.create(this, buttonRollOver);

// debug function
function debug (txt:String) {
        //trace(txt);
}

_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to