View Full Version : Color's Help plz
underworldling
12-21-2006, 05:10 PM
I'm trying to make a different color line depending on the value of tries, from 1-50. this is how i've done it but i'm sure there is an easier way. i just don't know it. if there is plz help me out. thx
if (tries == 1) {
mandel.lineStyle ( 1, 0xFFFF00, 100 ) ;
mandel.moveTo(i, j);
mandel.lineTo(i+1, j+1);
}
if (tries == 2) {
mandel.lineStyle ( 1, 0xFFF900, 100 ) ;
mandel.moveTo(i, j);
mandel.lineTo(i+1, j+1);
}
if (tries == 3) {
mandel.lineStyle ( 1, 0xFFE900, 100 ) ;
mandel.moveTo(i, j);
mandel.lineTo(i+1, j+1);
}
if (tries == 4) {
mandel.lineStyle ( 1, 0xFFD900, 100 ) ;
mandel.moveTo(i, j);
mandel.lineTo(i+1, j+1);
}
if (tries == 5) {
mandel.lineStyle ( 1, 0xFFC900, 100 ) ;
mandel.moveTo(i, j);
mandel.lineTo(i+1, j+1);
}
... i think you get the pattern.
if (tries >0 && tries <9) {
mandel.lineStyle ( 1, 0xFFFF00, 100 ) ;
mandel.moveTo(i, j);
mandel.lineTo(i+1, j+1);
}
if (tries >9 && tries <19) {
mandel.lineStyle ( 1, 0xFFF900, 100 ) ;
mandel.moveTo(i, j);
mandel.lineTo(i+1, j+1);
}
Like that?
underworldling
12-21-2006, 05:27 PM
no. i want all the in between color changes aswell. is there some way i could do it with an array maybe?
Logic
12-21-2006, 05:28 PM
I usually don't do much with drawing lines dynamically but when you're looking to transform the colors of something, you should look into the colorTransform class.
Simply open Flash 8 (8 is required, either standard or pro), press F1, and read about it. See if that provides any insight into solving your problem.
I checked your conditions though and they all look correct but I think the possible problem could lie in the methods you are using.
Most dynamically drawn lines (like you are using) require an empty movie clip to work from what I remember.
Try adding a piece of code like:
//place in root timeline, whichever frame the line needs to be in
this.createEmptyMovieClip('mandel', this.getNextHighestDepth());
mandel._x = ?
mandel._y = ?
If you can use a normal movieclip, by all means use it. I would advise (if possible) to simple make a 'mandel' movieclip that is simply a black line. Then using the colorTransform class, you can change the color. Also, because it is a movieclip, you can move it how you see fit by using mandel._x and mandel._y properties.
Let me know if it works, and good luck coding!
Riokou
12-21-2006, 07:09 PM
Hm...
colors=["0xFFFF00", "0xFFF900", "0xFFE900", "0xFFD900", "0xFFC900"]
for(i2=0; i2<=colors.length; i2++){
if(tries==i2){
mandel.lineStyle (1, colors[tries], 100+tries);
mandel.moveTo(i, j);
mandel.lineTo(i+1, j+1);
}
}
I'm not sure if 'colors.length' should be 'colors._length'
All you have to do is put more colors in the 'colors' array. I'm pretty sure this gets the job done.
Jacob
12-21-2006, 07:29 PM
Its ".length"
I dont see the need to have the for loop and the If statement, other than that its almost what he needs.
arkhan
12-21-2006, 08:19 PM
thats would be too much CPU wasted..
for the array method you dont need the for loop..
colors=["0xFFFF00", "0xFFF900", "0xFFE900", "0xFFD900", "0xFFC900"]
//on tries change or onEnterFrame, whatever you fell like
mandel.lineStyle ( 1, colors[tries], 100 ) ;
mandel.moveTo(i, j);
mandel.lineTo(i+1, j+1);
I would tell you to use the colorTransform class as well..
import flash.geom.ColorTransform
var colTrans:ColorTransform = new ColorTranform(1,1,1,1,255,255,0,255);
//and every time tries change you subtract the green value
colTrans.greenOffset(colTrans.greenOffset-10);//its great this is a property AND a method..
by every time tries change I mean lasttries!=tries
to get the hex value from color Transform you just have to use toString(16)
[code]
trace("0x"+coltrans.rgb.toString(16));//0xffff00
underworldling
12-21-2006, 11:01 PM
thanx alot guys! all this info has helped me alot
vBulletin® v3.7.3, Copyright ©2000-2010, Jelsoft Enterprises Ltd.