# Dynamic background color

**URL:** <https://forum.kirupa.com/t/dynamic-background-color/181782>\
**Category:** Uncategorized\
**Created:** [March 13, 2006, 1:40am UTC](https://forum.kirupa.com/t/dynamic-background-color/181782 "2006-03-13T01:40:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![lejon](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/lejon/32/2181_2.png) [@lejon](https://forum.kirupa.com/u/lejon)\
**Post date:** [March 13, 2006, 1:40am UTC](https://forum.kirupa.com/t/dynamic-background-color/181782/1 "2006-03-13T01:40:56Z")

</div>

i have background colors saved in a mysql file and outputting them into flash readable strings on a php page:

```php
&bgColor=0xFFFFFF

```

then i use this actionscript to pull it off the php page:

```php
 
myData = new LoadVars();
myData.onLoad = function() {
putData();
};
//
myData.load("http://www.mysite.com/phpvariables.php");
putData = function(){
colorholder_txt.text = myData.bgColor;
}

```

so thats great, i can view what color i would like the background to be by its color code in my text box “colorholder\_txt”.

now what if i have a generic box drawing script that i want this box to take the color of the php variable loaded color:

```php
 
this.createEmptyMovieClip("bg_mc", 0);
drawRectangle(bg_mc, Stage.width, Stage.height, ***colorholder_txt.text*** , 100);
function drawRectangle(target_mc:MovieClip, boxWidth:Number, boxHeight:Number, fillColor:Number, fillAlpha:Number):Void {
with (target_mc) {
beginFill(fillColor, fillAlpha);
moveTo(0, 0);
lineTo(boxWidth, 0);
lineTo(boxWidth, boxHeight);
lineTo(0, boxHeight);
lineTo(0, 0);
endFill();
}
}

```

is there a way to make this box the designated color when the page loads?
