- Home
- Tutorials
- Flash
- Intermediate
- Random Color transition
Random Color transition

page1
SlickRik
This user is yet to take control of their account and provide a biography. If you are the author of this article, please contact us via support AT actionscript DOT org.
View all articles by SlickRikDownload FLA
This is a script i made for colortransitions in pictures. If you know photoshop and u adjust the hue in a picture it can give you some very cool effects. I wanted to create this effect in Flash. Now I think there are some ways to make the script a lot shorter.
So be my guest use and adjust this script. Mail me your opinion or suggestions @ rikv_AThotmail.com. Thanx!
p.s. black and white pics give the nicest effect!!
<<<<Add this script to the mc you want to look weird. Add it by selecting the mc and just add the script :D>>>>
onClipEvent(load) {
myColor = new Color(this); //Make myColor a new color for this mc.
colorTrans = new Object(); //Make colorTrans a new object. Dimensions and properties will be added later.
//If you adjust colors from MC's you have red green blue and alpha. ra is the percentage of red in the mc. It can be from
//-1000% till 1000%. rb is the value of red to add or substract it can be -512 till 512. Play with these settings in the
//property's of your mc and see what i mean before using this script.
a = (random(2001)-1000);?
b = (random(2001)-1000);
c = (random(2001)-1000);
x = (random(1025)-512);
y = (random(1025)-512);
z = (random(1025)-512);
//Make random values so from start the mc wont look normal and the transition in the picture is more random, this is
//done so you wont see the same colors in the pictures over and over again.
RandArray = new Array(-10,10);
da = RandArray[random(1)];
db = RandArray[random(1)];
dc = RandArray[random(1)];
dx = RandArray[random(1)];
dy = RandArray[random(1)];
dz = RandArray[random(1)];
// -10 and + 10 will be chosen from this array. One color adjustment will go up and the
//other will go down due to this.
}
onClipEvent(enterFrame) {
if(a<-1000) {
a = -1000;
da = 10+(random(11)-5);
}
if(a>1000) {
a = 1000;
da = -10+(random(11)-5);
}
if(b<-1000) {
b = -1000;
db = 10+(random(11)-5);
}
if(b>1000) {
b = 1000;
db = -10+(random(11)-5);
}
if(c<-1000) {
c = -1000;
dc = 10+(random(11)-5);
}
if(c>1000) {
c = 1000;
dc = -10+(random(11)-5);
}
if(x<-512) {
x = -512;
dx = 10+(random(11)-5);
}
if(x>512) {
x = 512;
dx = -10+(random(11)-5);
}
if(y<-512) {
y = -512;
dy = 10+(random(11)-5);
}
if(y>512) {
y = 512;
dy = -10+(random(11)-5);
}
if(z<-512) {
z = -512;
dz = 10+(random(11)-5);
}
if(z>512) {
z = 512;
dz = -10+(random(11)-5);
}
//The previous part will make sure none of the color values will go over the maximum point. Then it will go vice versa and
//adjusts is with random(5) so every time the color fading it will go faster or slower.I guess this can be a lot
//shorter but hey.... I still suck...:P
colorTrans = {ra:a,rb:x,ga:b,gb:y,ba:c,bb:z,aa:'100',ab:'0'}; //Set the dimension and values inside of object colorTrans.
myColor.setTransform(colorTrans); //setTransform applies the color to the mc.
a = a + da;
b = b + db;
c = c + dc;
x = x + dx;
y = y + dy;
z = z + dz;
//Adds and substract the values from the color values.
}
My next plan is to set boundaries. Cause now some times u see the whole picture in one solid color. I dont like that. This can be done in two ways. 1 Set boundaries where the values wont go over. 2 Use a hsl to rgb conversion formula. Then only adjust the hue. convert it back to rgb values and use those. This is my favorite!! Greetings Slickrik a.k.a. Rik Vermeer .
Have fun wit hit!!!! Thanx for all the knowlegde that is found on your site!!! Mail me if u need a dutch translation from this tutorial.
Greetings SlickRik

