Skip to main content
Inspiring
April 9, 2007
Question

how to setup a Desaturation Tween

  • April 9, 2007
  • 48 replies
  • 4046 views
Hi just a quick question, i have a function to swap depths and tween the _alpha property of some movie clips, ---=> Thanx kglad <=--- but i was wondering if theres a way to change the color property without filters??
im especially interested in the Saturation / De-Saturation for this idea i have.

or do i need to use import flash.filters to do this?

if this is the only way, i dont think it will be worth it, unless creating a function for it is simple.

Thanx in advance.
This topic has been closed for replies.

48 replies

kglad
Community Expert
Community Expert
April 10, 2007
actually the tween class is much more flexible than just handling movieclips and their properties. it's able to handle any object and its property.

so, with the color tween i created an object (obj=new Object() ) which serves no other purpose than to allow me to create a property of that object ( r ) that can be tweened from 0 (=0x00) to 255 (=0xff).

the only place i need to use the movieclip is to create a color object of the movieclip (c=new Color(mc) ). it's the color object that i'm going to manipulate (using setRGB() ).
SketchstaAuthor
Inspiring
April 10, 2007
its like the setInterval i learnt a while ago... I still dont really understand why it works, because of the params.

the way i know setInterval is..

interval_name.setInterval( function name , how often);

two params..

the one that i still dont understand is..

interval_name.setInterval( timeline, " command ", how often );

i use this to pause the playhead..and sure enough, it works like magic.. but i dont understand why..
because theres no function being called...and this doesnt repeat like the one i use, this stops, for the amount you set in the last param..

I looked at it for ages, and tried to read the help docs on setInterval... but couldnt find anything.. so i just gave up, but i still use it. =)
kglad
Community Expert
Community Expert
April 10, 2007
the two ways to use setInterval() are explained in the help documents under actionscript 2.0 language reference/actionscript classes/index/setInterval().
SketchstaAuthor
Inspiring
April 10, 2007
thats kool, you just made your own function hey?

I dont understand why it works though. I thought the params for Tween are...

(movieClip, " what attribute to tween ", extra effects, start, destination, length, seconds or timeline);

i see all of those in your function, but i dont see the attribute to tween.. I see where you set r to be 0, but thats it.
i dont see how r is a attribute to be changed...

also, the beginning of the attributes, you have Obj as the movieClip... the way i understand and the way i would have tried to do this, is to have mc instead of Obj, because the movieClip called mc is the one im trying to affect..

You have just confused me with the little that i know about Tweens =)
It's probably a good thing though, if i dont learn this way of doing it, i might be learning the Tween class all wrong.
SketchstaAuthor
Inspiring
April 9, 2007
yeah thats the first thing i tried. =)
the only problem is that the green and blue values are applied right from the start, which i kinda already guessed..
but the point is that i know they can be changed now.

i tried it with one of the folder symbols from the main .fla, to get an idea of what strength i want the color..
and i also added the new thing i learnt... Tween the _alpha. =)

it's looking not as good as i thought it would, but with abit more tweaking it could be alright.

i'm gonna try n write your function by myself, but for the green and blue.
I know this is alot of extra typing, making a separate function for each..but atleast this one i understand. and by typing it, i will remember it.

Are arrays really important to know?
I dont know what really good uses they have, so I never stumbled accross any use for them to learn..

One thing i REALLY have to learn, is how to make custom functions ( I dont know what else to call them ).
The kind where you can call it AND tweak it by adding properties.

for example, i make 3 buttons to call to this function you made, but from each button the function is called, i can set the properties for it.

btn1.onRelease = function(){
testF(12,55,90);
}

like that...to set the 3 colors.
I need to study a couple of those type of functions. I have one for drawing a rounded rectangle, LuigiL gave me a while ago.
i'll get on that after i learn more tweening and maybe learn the array function you gave me first. =)

You know what... people like You, David Stiller, and LuigiL, should write the help docs for Flash.. everyone would learn alot easier if the help docs were easier to understand.

anyway, THANX yet again,
you're always a good source for learning. =)
kglad
Community Expert
Community Expert
April 9, 2007
you can use the tween class to control the red, green and blue variables if you get inspired:

kglad
Community Expert
Community Expert
April 9, 2007
yes, that's a tween using a setInterval() loop.

the toString(16) converts that number to a base 16 (hexadecimal) number. otherwise, flash converts those hex numbers (like 0xff) into decimals. and with decimal numbers it's more complicated to control the red, green and blue colors.

i think the best way to learn is to experiment. so, go for it. try:

col+=rComp+"00ff";
// and then try
col+=rComp+"ff00";
// etc
SketchstaAuthor
Inspiring
April 9, 2007
hahaha, you knew exactly what i was having problems with.. =P

yeah that makes more sense to me now. All thats left is for me to play round with it until I fully understand it.

from looking at it ( for the last 20mis ) this is a tween on it's own right?
it increases every 50ms and clears tetsI when it reaches max red.

what about the 16? what is that ?
only thing i can think of is the HUE of the red, from 0 - f... is that right?

col += rCom+"0000"; if i was to change these values, would it have an effect on the color?
or does it need to be declared as green and blue?

ok, well im gonna go try this in a new .fla, and see what i can learn from it.

Thanx again dude, with your help i'll be as good as you in half my life time..=P
SketchstaAuthor
Inspiring
April 9, 2007
WOW!!!

i cant even begin to understand that...
I can sort of guess what it does by the few lines of code that i understand and know... but the bulk of it..it's just out of my league..

the comments are gonna help me abit.. but i dont even understand the syntax you used...

all i hoped to do is add color to the menu that is clicked and tween to grayscale when not in focus..
but i dont think thats gonna happen with this menu. =)

thanx alot anyway. but you've shown me that this is out of my league. =)
kglad
Community Expert
Community Expert
April 9, 2007
here's that code without the array notation (and only for the r or red component of the color):

kglad
Community Expert
Community Expert
April 9, 2007
you could use tweening and the color class or colortransform class if you want to avoid bitmaps.
SketchstaAuthor
Inspiring
April 9, 2007
thanx for the help again =)

i had a read through the help docs, and i found and tried this code.

how can i combine this with the _alpha tween you helped me with before?

thats a whole lot of paramiters to remember too...I was thinking something like..
six._color = 0x995588 ;

but i guess that would just be too easy. =)
kglad
Community Expert
Community Expert
April 9, 2007
yes, there's no super easy way to handle color in flash. the color class is the easiest and most intuitive to understand but it has its own share of problems when you use it because you must make an effort to control each color component (r, g and b) separately.

here's an example: