Copy link to clipboard
Copied
I want to create a template, in this template i want the user to be able to view certain object in whatever color they choose, in addition to them choosing a color i want the color to fade into the next color smoothly.
don't attach code to objects and you can use colorF to color tween the first argument using the colors in the 2nd and 3rd arguments over the 4th arguments duration (in seconds):
import mx.transitions.Tween;
import mx.transitions.easing.*;
import flash.geom.ColorTransform;
var rTween:Tween;
var gTween:Tween;
var bTween:Tween;
var colorObj:Object = {};
var mc_color:MovieClip;
var ct:ColorTransform;
colorF(mc,0xff0000,0xaaffff,1);
function colorF(mc:MovieClip,startColor:Number,endColor:Number,duration:Number)
...Copy link to clipboard
Copied
here is the code im trying to use
on (release) {
colorme.colorTo(0x00FF00,2.5);
}
Copy link to clipboard
Copied
don't attach code to objects and you can use colorF to color tween the first argument using the colors in the 2nd and 3rd arguments over the 4th arguments duration (in seconds):
import mx.transitions.Tween;
import mx.transitions.easing.*;
import flash.geom.ColorTransform;
var rTween:Tween;
var gTween:Tween;
var bTween:Tween;
var colorObj:Object = {};
var mc_color:MovieClip;
var ct:ColorTransform;
colorF(mc,0xff0000,0xaaffff,1);
function colorF(mc:MovieClip,startColor:Number,endColor:Number,duration:Number):Void{
rTween = new Tween(colorObj,'red',None.easeNone,(startColor&0xff0000)>>16,(endColor&0xff0000)>>16,duration,true);
gTween = new Tween(colorObj,'green',None.easeNone,(startColor&0x00ff00)>>8,(endColor&0x00ff00)>>8,duration,true);
bTween = new Tween(colorObj,'blue',None.easeNone,startColor&0x0000ff,endColor&0x0000ff,duration,true);
mc_color = mc;
ct = mc.transform.colorTransform;
rTween.onMotionChanged = colorChangeF;
}
function colorChangeF():Void{
ct.rgb = Math.round(colorObj.red)<<16 | Math.round(colorObj.green)<<8 | Math.round(colorObj.blue);
mc_color.transform.colorTransform = ct;
}
Copy link to clipboard
Copied
ok im still pretty new at this so i have my three test buttons set up and the area i want to be colored.. if i understand you correctly
import mx.transitions.Tween;
import mx.transitions.easing.*;
import flash.geom.ColorTransform;
var rTween:Tween;
var gTween:Tween;
var bTween:Tween;
var colorObj:Object = {};
var mc_color:MovieClip;
var ct:ColorTransform;
colorF(mc,0xff0000,0xaaffff,1);
this part all goes into by button area and the rest goes onto the stage area//// or does it go inside the object i want to be colored
Copy link to clipboard
Copied
Actually I figured it out my only question is..
function colorF(mc:MovieClip,startColor:Number,endColor:Number,duration:Number):Void{
on the startColor:Number is there a way that I can make it start from any previous color I used for example.... if I clicked on blue than clicked on green is there a way I can make the
code start from the previous color without always making a startColor:Number
the reason I want to know is because if I want to have a lot of colors to choose from I don't want to have to keep creating a startColor:Number for each and every keyframe.
Your code works amazing but I tweaked it a little.
function colorF(mc:MovieClip,endColor:Number,duration:Number):Void{
I took out the startColor:Number and it works excellent but whenever I click a different color it default back to black before getting to its color.
Copy link to clipboard
Copied
yes, save the previous endColor so you can use that as the next startColor. eg,
function colorF(mc:MovieClip,startColor:Number,endColor:Number,duration:Number):Void{
mc.endColor=endColor;
rTween = new Tween(colorObj,'red',None.easeNone,(startColor&0xff0000)>>16,(endColor&0xff0000)>>16,dura tion,true);
gTween = new Tween(colorObj,'green',None.easeNone,(startColor&0x00ff00)>>8,(endColor&0x00ff00)>>8,dura tion,true);
bTween = new Tween(colorObj,'blue',None.easeNone,startColor&0x0000ff,endColor&0x0000ff,duration,true);
mc_color = mc;
ct = mc.transform.colorTransform;
rTween.onMotionChanged = colorChangeF;
}
function colorChangeF():Void{
ct.rgb = Math.round(colorObj.red)<<16 | Math.round(colorObj.green)<<8 | Math.round(colorObj.blue);
mc_color.transform.colorTransform = ct;
}
then whenever you want to color-tween something:
if(mc.endColor){
colorF(mc,mc.endColor,endColor,1);
}
(p.s when using the adobe forums, please mark helpful/correct responses, if there are any.)
Copy link to clipboard
Copied
I hit the correct button in the forum.. But what i want to do is a little more complex and its hard to explain in text, I know you would not want random people calling you all day so if you don't mind here is my cell phone number if you can call me so that i can better explain what Im trying to do that will be much appreciated.
you can call me from a blocked number
My name is Charles661.618.6436
Copy link to clipboard
Copied
if you want to hire me to help, please send me an email via my website: http://www.kglad.com
in addition, to my flash-for-pay work i donate considerable time and effort to the flash community by trying to help people that post on the 3 main (as1/as2, as3, flash) adobe flash forums. if you want free help, post your issue to the appropriate forum. if i am able and interested in your issue, i will probably respond. and, if i don't, someone else probably will.
if you state your issue clearly, and especially if you pinpoint the problem, you almost certainly will be helped free of charge. if you have a complex problem and especially if you require source (fla and/or as) files to be corrected, you almost certainly should consider hiring someone to help. again, you can hire me via my website.
thank you for understanding,
kglad
Flash Consulting Services
www.kglad.com
Find more inspiration, events, and resources on the new Adobe Community
Explore Now