# \[Flash 8/AS2\] Best way to pass color variable from xml to MC

**URL:** <https://forum.kirupa.com/t/flash-8-as2-best-way-to-pass-color-variable-from-xml-to-mc/274594>\
**Category:** flash\
**Created:** [October 31, 2008, 8:20pm UTC](https://forum.kirupa.com/t/flash-8-as2-best-way-to-pass-color-variable-from-xml-to-mc/274594 "2008-10-31T20:20:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sw2geeks](https://avatars.discourse-cdn.com/v4/letter/s/cdc98d/32.png) [@sw2geeks](https://forum.kirupa.com/u/sw2geeks)\
**Post date:** [October 31, 2008, 8:20pm UTC](https://forum.kirupa.com/t/flash-8-as2-best-way-to-pass-color-variable-from-xml-to-mc/274594/1 "2008-10-31T20:20:57Z")

</div>

I have an XML file that is passing the color that is needed on a movie clip.

I can make the color variable in the XML the actual HEX number and that works fine.

Example:

```auto

//XML
<ColorData>
   <!--1001-->
   <ClipColor mcColor="0x990000" /ClipColor>
</ColorData>

//Actionscript

my_xml = new XML();
my_xml.load("ColorMC.xml");
my_xml.onLoad = my_function;
my_xml.ignoreWhite = 1;

function my_function() {
    
var mc1001color = my_xml.firstChild.childNodes[0].attributes.mcColor;
    
    
var newcolor1001:Color = new Color(mc_1001);
newcolor1001.setRGB(mc1001color);

}

```

But I would like to change the hex number in the xml into a a color name like red,  
blue, green or gray to make it less confusing to the person generating the xml.  
But I am having trouble tring to figure out how to change the color name back to the hex numbers  
in the actionscrit.

I tried declaing the color names as variables with the hex numbers, but I am kind of stuck,  
Everything I tried so far has not worked.

```auto

//XML
<ColorData>
   <!--1001-->
   <ClipColor mcColor="Red" /ClipColor>
</ColorData>

//Actionscript

my_xml = new XML();
my_xml.load("ColorMC.xml");
my_xml.onLoad = my_function;
my_xml.ignoreWhite = 1;

function my_function() {
    
var mc1001color = my_xml.firstChild.childNodes[0].attributes.mcColor;

var Red = 0x990000;
var Blue = 0x013E98;
var Green = 0x09913F;
var Gray = 0xBFBFBF;

var newcolor1001:Color = new Color(mc_1001);
newcolor1001.setRGB(mc1001color);

}

```

There are actully going to be over 600 movie clips to color so I would like to keep the code simple  
and swap the hex number for the color names just once if posable.

Thanks for any help.
