Actionscript color
- Started
- Last post
- 43 Responses
- stewart
Q:
i have two black square movieclips in FlashMX, let's say MC1 and MC2
i also have an external .txt file with "MC1=#FF3300 MC2=#FF3366"
how can i make it that MC1 and MC2 are colored with their colors?
- function820
try
mc_name.setRGB(MC1);
- ********0
Thats sort of right, You need to use the color class.
my_color = new Color(MC1);
my_color.setRGB(0xFF3300);
- stewart0
ok, thanks.
but the question is: what if i have the color in an external .txt document so i can change it every now and then without opening the fla file?
someone has an example of that?
- ozhanlion0
create a color.txt and add this line.
clr="whateveryoulike"in flash;
myLoadVars = new loadVars();
myLoadVars.load("color.txt");
myLoadVars.onLoad = function(success) {
// If the loaded data was decoded, display the title property.
if (success) {
my_color = new Color(MC1);
my_color.setRGB(this.clr);
} else {
trace("Unable to load the title.");
}
- ozhanlion0
that was quick.
don't put quotes between whateveryoulike and don't mind the spaces in the previous post.
- stewart0
thanks oz,
that looks like something in the good direction.
but i can't still get it work like it should...
- JamesEngage0
I did it for the http://www.mill.co.uk banner... you have to mix between splitting your colours into 255,255,255 numbers and hex.... but doing this also allows you to tween.
- stewart0
james! brilliant!
the tween function has to be in it too.
can you tell me some more about the technique or is it top secret?
- JamesEngage0
not sure if I have it to hand... but I'll have a look
my values were not external, but it is v. easy to sort that
- ********0
are you talking about a gradual transform from one colour to another, using the colour object?
I would be dead keen to see that too..been thinking of sitting down and writing a method for that but havn't bothered yet.
- ozhanlion0
very clever menu james. I really like the transitions.
- stewart0
thanks james.
but if you have some info about how to put the color values external, it would be great to!
- vespa0
me three
- stewart0
...great too!
*cough
- JamesEngage0
check your mail
- silencer0
i'd be interested to see how you did that as well too James if its not too much hassle :0)
- JamesEngage0
hope it helps... you can replace the values... eg white etc. with your external ones etc.
just bring in the values through a text file
- JamesEngage0
I'm all up for open source and sharing and all that... but funny when everyone comes out of the woodwork! this place was dead all morning. Spongers! :)
- stewart0
thanks a lot james!
i never ever worked with arrays etc before, only done simple websites in flash like my sisters website.
but i'll give it a try!
- stewart0
i was here all morning (european time!)