12-10-2002, 08:37 AM
|
#1
|
|
Registered User
Join Date: Dec 2002
Posts: 26
|
setRGB
I have a question regarding setRGB :
When I specify the RGB value, does it have to be hexadecimal? How could I define the value otherwise? If this isn't possible, how can I convert two strings into a hexadecimal value?
I REALLY appreciate any help, I am lost, I have already tried the eval funtion, and I'm not sure if parseInt will do it.
Thank you, best regards,
|
|
|
12-10-2002, 08:43 AM
|
#2
|
|
Registered User
Join Date: Dec 2002
Posts: 26
|
LOL
I tried the parseInt and it worked! Thanks anyway!
parseInt("0x"+theString);
|
|
|
12-10-2002, 09:32 AM
|
#3
|
|
Registered User
Join Date: Dec 2002
Posts: 26
|
Actually, it doesn't really work right, for some reason I still can't change the color :
Var1rgb = "FF0000";
Var2rgb = "00FF00";
Var3rgb = "0000FF";
Var4rgb = "FFFF00";
Var5rgb = "00FFFF";
_root.1FillArray = ['1ClipInstance.1FillClipInstance','2ClipInstance.2 FillClipInstance','3ClipInstance.3FillClipInstance ','4ClipInstance.4FillClipInstance','5ClipInstance .5FillClipInstance'];
for (var i=1;i<=_root.1FillArray.length;i++) {
color = eval("Var"+i+"rgb");
thecolor = new Color(_root[_root.1FillArray[i]]);
colorparsed = parseInt("0x"+color);
thecolor.setRGB(colorparsed);
}
What is wrong with this? I know that this works :
thecolor = new Color(_root.2ClipInstance.2FillClipInstance);
colorparsed = parseInt("0x"+Var2rgb);
thecolor.setRGB(colorparsed);
What should I do? Should I define each RGB value individually?
Thanks,
Best regards:
|
|
|
12-10-2002, 10:28 AM
|
#4
|
|
Addicted To FLASH
Join Date: Dec 2001
Location: Egyptian in UAE
Posts: 12,439
|
I got lost, can u tell us exactly what you wanna do here
__________________
â€* GOD Is Near â€*
Questions Don't PM for Questions . Thanks
An eye for an eye, make the whole world blind
_____________________________________________GHANDI
|
|
|
12-10-2002, 11:19 AM
|
#5
|
|
Registered User
Join Date: Dec 2002
Posts: 26
|
I want to create a hexadecimal value from two strings, one containing "0x" and the other one containing the value, for example "FF0000". The problem is that flash can not interpret a string as a prameter when setting the RGB value. To do this, I take the two strings, concatenate them, and parseInt them into a numerical value that represents the hexadecimal value.
"0x"+"FF0000" => "0xFF0000" => parseInt("0xFF0000") => number.
This method works. Now I have to add something to this since I have to change the color of a lot of objects at once, that is, there are several instances that need to have their color changed, and they all have similar names. So I created an array to hold the instance names. Then I named the variables according to their position in the array. The problem is that at every point in the loop i need to access a different variable :
if i = 1, then "Var"+i+"rgb" => Var1rgb, where Var1rgb is FF0000
and then I concatenate it together with the "0x" as shown above. So the resulting string becomes "0xFF0000" again. Now when I run a parseInt it converts it into a number, however it still doesn't change the color... Please help!
|
|
|
12-10-2002, 11:40 AM
|
#6
|
|
Addicted To FLASH
Join Date: Dec 2001
Location: Egyptian in UAE
Posts: 12,439
|
I got it, ahuh
now the problem isn't with the parseInt(), but with the array "1FillArray"
never start any name in flash with a number
__________________
â€* GOD Is Near â€*
Questions Don't PM for Questions . Thanks
An eye for an eye, make the whole world blind
_____________________________________________GHANDI
|
|
|
12-10-2002, 11:45 AM
|
#7
|
|
Registered User
Join Date: Dec 2002
Posts: 26
|
Ok, changed it to movie1FillArray, but it still doesn't work..
|
|
|
12-10-2002, 11:51 AM
|
#8
|
|
Addicted To FLASH
Join Date: Dec 2001
Location: Egyptian in UAE
Posts: 12,439
|
Also change all the array elements, it it's still off, try to post it here
__________________
â€* GOD Is Near â€*
Questions Don't PM for Questions . Thanks
An eye for an eye, make the whole world blind
_____________________________________________GHANDI
|
|
|
12-10-2002, 12:04 PM
|
#9
|
|
Registered User
Join Date: Dec 2002
Posts: 26
|
I checked them all...
_root.movie1FillArray = ['movie1ClipInstance.movie1FillClipInstance','movie 2ClipInstance.movie2FillClipInstance','movie3ClipI nstance.movie3FillClipInstance','movie4ClipInstanc e.movie4FillClipInstance','movie5ClipInstance.movi e5FillClipInstance'];
for (var i=1;i<=_root.movie1FillArray.length;i++) {
color = "0x"+eval("Wolke"+i+"rgb");
thecolor = new Color(_root[_root.movie1FillArray[i]]);
colorparsed = parseInt(color);
thecolor.setRGB(colorparsed);
TextField9 += " || movie"+i+"COLORPARSED = "+colorparsed+" : COLOR"+i+"RAW = "+color+"[RED="+red+"green="+green+"blue="+blue+"]";
}
I think there is nothing wrong with the hex values actually, because usually when you insert a string instead of a hex value the mc turns black. Right now, nothing happens...
Thanks a lot for your time...
regards:::
Last edited by Boethius; 12-10-2002 at 12:06 PM.
|
|
|
12-10-2002, 12:22 PM
|
#10
|
|
Addicted To FLASH
Join Date: Dec 2001
Location: Egyptian in UAE
Posts: 12,439
|
ok, here is the working code
ActionScript Code:
_root.movie1FillArray = ['movie1ClipInstance.movie1FillClipInstance', 'movie2ClipInstance.movie2FillClipInstance', 'movie3ClipInstance.movie3FillClipInstance', 'movie4ClipInstance.movie4FillClipInstance', 'movie5ClipInstance.movie5FillClipInstance'];
for (var i = 1; i<=_root.movie1FillArray.length; i++) {
myColor = "0x"+"Wolke"+i+"rgb";
trace(myColor);
thecolor = new Color(_root[_root.movie1FillArray[i]]);
colorparsed = parseInt(myColor);
thecolor.setRGB(colorparsed);
TextField9.text = " || movie"+i+"COLORPARSED = "+colorparsed+" : COLOR"+i+"RAW = "+color+"[RED="+red+"green="+green+"blue="+blue+"]";
}
there was a problem also with using the "color" object as a variable, so I'v changed it to myColor
__________________
â€* GOD Is Near â€*
Questions Don't PM for Questions . Thanks
An eye for an eye, make the whole world blind
_____________________________________________GHANDI
|
|
|
| Thread Tools |
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT. The time now is 08:16 PM.
|
|