# Problem in setting RGB

**URL:** <https://forum.kirupa.com/t/problem-in-setting-rgb/206761>\
**Category:** Uncategorized\
**Created:** [November 11, 2006, 1:23am UTC](https://forum.kirupa.com/t/problem-in-setting-rgb/206761 "2006-11-11T01:23:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![zigolleid](https://avatars.discourse-cdn.com/v4/letter/z/977dab/32.png) [@zigolleid](https://forum.kirupa.com/u/zigolleid)\
**Post date:** [November 11, 2006, 1:23am UTC](https://forum.kirupa.com/t/problem-in-setting-rgb/206761/1 "2006-11-11T01:23:47Z")

</div>

What I’m trying to do right now is to extract a numerical value from an XML file and change the color of an object accordingly. Here’s what I have wrote:

onClipEvent (mouseMove) {  
var gdp = 0;  
for (var i = 0; i\<\_root.world.length; i++) {  
if (\_root.world\*.attributes.name == “Asia”) {  
var asia = \_root.world\*.childNodes;  
for (var j = 0; j\<asia.length; j++) {  
if (asia[j].attributes.name == “South Korea”) {  
var korea = asia[j].childNodes;  
for (var k = 0; k\<korea.length; k++) {  
if (korea[k].nodeName == “GDP” && korea[k].attributes.year == \_root.year) {  
gdp = korea[k].firstChild.nodeValue;  
}  
}  
}  
}  
}  
}  
colorobj = new Color(this.korea);  
trace(colorobj.getRGB());  
var colorValue = (gdp/5000)\*255;  
var R = (255 - colorValue)_65536;  
var G = colorValue_256;  
var B = 0;  
colorobj.setRGB(R+G+B);  
}

The looping part works fine. I could get the value I wanted. The color change part also worked fine by itself. When I put a certain number in _gdp_ and the color was set successfully.  
The problem is when I combine these two together. Not only _korea_’s color wasn’t changed, but _trace(colorobj.getRGB());_ showed _undefined_ instead of displaying the original color’s code.  
Can anyone tell me what’s wrong? I’m really stuck…
