# Changing MC color with external variable

**URL:** <https://forum.kirupa.com/t/changing-mc-color-with-external-variable/23601>\
**Category:** flash\
**Created:** [June 20, 2003, 1:11am UTC](https://forum.kirupa.com/t/changing-mc-color-with-external-variable/23601 "2003-06-20T01:11:10Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Freddythunder](https://avatars.discourse-cdn.com/v4/letter/f/8edcca/32.png) [@Freddythunder](https://forum.kirupa.com/u/Freddythunder)\
**Post date:** [June 20, 2003, 1:11am UTC](https://forum.kirupa.com/t/changing-mc-color-with-external-variable/23601/1 "2003-06-20T01:11:10Z")

</div>

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/colortest.fla)  
[http://freddythunder.com/test/var.txt](http://freddythunder.com/test/var.txt)

Anyone??:\*(

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 20, 2003, 2:46am UTC](https://forum.kirupa.com/t/changing-mc-color-with-external-variable/23601/2 "2003-06-20T02:46:23Z")

</div>

hmm i dunn0, looks like it shoudl work to me

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 20, 2003, 3:00am UTC](https://forum.kirupa.com/t/changing-mc-color-with-external-variable/23601/3 "2003-06-20T03:00:30Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 20, 2003, 3:01am UTC](https://forum.kirupa.com/t/changing-mc-color-with-external-variable/23601/4 "2003-06-20T03:01:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 20, 2003, 5:25am UTC](https://forum.kirupa.com/t/changing-mc-color-with-external-variable/23601/5 "2003-06-20T05:25:22Z")

</div>

the code:

```auto
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:

```auto
newColor=FF0000 **&**

```

😉

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 20, 2003, 5:34am UTC](https://forum.kirupa.com/t/changing-mc-color-with-external-variable/23601/6 "2003-06-20T05:34:36Z")

</div>

Thx Kax  
I was almost there  
:thumb:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 20, 2003, 5:36am UTC](https://forum.kirupa.com/t/changing-mc-color-with-external-variable/23601/7 "2003-06-20T05:36:33Z")

</div>

😉 =)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 20, 2003, 5:50am UTC](https://forum.kirupa.com/t/changing-mc-color-with-external-variable/23601/8 "2003-06-20T05:50:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 20, 2003, 5:52am UTC](https://forum.kirupa.com/t/changing-mc-color-with-external-variable/23601/9 "2003-06-20T05:52:37Z")

</div>

> _Originally posted by Freddythunder_  
> **…well, I did have a txt file…**

😛

you’re welcome, Freddy. :beam:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 20, 2003, 5:56am UTC](https://forum.kirupa.com/t/changing-mc-color-with-external-variable/23601/10 "2003-06-20T05:56:53Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 20, 2003, 6:13am UTC](https://forum.kirupa.com/t/changing-mc-color-with-external-variable/23601/11 "2003-06-20T06:13:22Z")

</div>

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. 😛

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 20, 2003, 6:19am UTC](https://forum.kirupa.com/t/changing-mc-color-with-external-variable/23601/12 "2003-06-20T06:19:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 20, 2003, 6:53am UTC](https://forum.kirupa.com/t/changing-mc-color-with-external-variable/23601/13 "2003-06-20T06:53:38Z")

</div>

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!!).
