Changing MC color with external variable

One Flippin Variable…

Okay, this is experimentation for a project I’m working on. I know you can do this, but I can’t figure it out. I’ve been searching the net, the forums, flashkit and got as far as I did.

I want to have a movieClip (circle) change it’s color to a hex value (newColor) from an external txt (or PHP) file.

In the fla, I have the change-the-color-code in the timeline (because I tried it from the MC and it does the same thing). The movieClip turns black and the value from the text file shows up in the textBox.

http://freddythunder.com/test/colortest.fla
http://freddythunder.com/test/var.txt

Anyone??:*(

hmm i dunn0, looks like it shoudl work to me

That’s what I thought!! Thanks for looking Digital…
Anybody else got an idea? Frye? Frye?

I got nowhere Freddythunder …
now im curious, i wanna learn dat

the code:

var lv = new LoadVars(), cCircle = new Color(circle);
lv.onLoad = function(success) {
	if (success) cCircle.setRGB("0x"+this.newColor);
};
lv.load("var.txt");

the .txt file:

newColor=FF0000**&**

:wink:

Thx Kax
I was almost there
:thumb:

:wink: =)

I wasn’t even close!! :*( …well, I did have a txt file…
Thank you once again Kax!!

Originally posted by Freddythunder
…well, I did have a txt file…

:stuck_out_tongue:

you’re welcome, Freddy. :beam:

Kax, what is the last & for in the text file? Is that just there if I wanted to make a string with other variables, or does it serve a purpose?

actually, i should have mentioned it… :-\

you should always end the variable (no matter if there’s only one variable in the .txt file) by an ampersand (&). i believe this only a applies to notepad (win), but flash adds a carriage return (\r) and a linefeed (
), or two carriage returns, something like that… i don’t remember exactly at this moment. :stuck_out_tongue:

Your footer scared the **** out of me, freddy. I had the volumme way up… lol

I’m sorry - I thought it was funny, but your the second person that I’ve scared, maybe I should change it to a ‘scream’ (just kidding!!).