How to control Flash stage Background color using External Text File

Hi Friends,

I have 2 problems while using external text file.

  1. How to control Flash stage Background color using External .txt File, I want to change the color of the movie background through an external .txt file.

  2. And how to load jpeg image in a flash file through an external .txt file.

Waiting for your replies
Thanks all

  1. There are a couple ways that I could think of doing this. One, you could use a server-side language to read your background hex color and plop it into the code of Flash’s object tag. Then the decision would have to be made before hand of what the background color is going to be. OR you can make a movieClip on the bottom layer to pretend it’s a background and then use setRGB to change the color of that movieClip - hence making the illusion of changing the background color.

  2. What??

  1. use notepad, fill the full path of .jpg:

save as “myPhoto.txt”

in flash, create emptymovieclip, named it “clipname”
code in frame:

url = new LoadVars(); 
url.onLoad = function() {
myText.text=this.location; // if you have dynamic text named "myText", the location is written in there

But, i try it locally and it works. never try it online. maybe you can change the path ie “

I don’t see why you would use a method like that, but okay. As for the quote, don’t forget the ‘http://’ in the front of your path or Flash won’t find it.

Actually guys as long as the folder containing the pics is a subdirectory of the folder containing the flash movie all you need it "folderWithPics/picName.jpg"
A bonus of doing it that way is you can set up everything offline and load it to the net with all the same setup, you don’t have to worry about changing all the paths and what not.
PS php can build a list of all the files in a folder so you don’t have to type them all out like that, plus it makes updating a sinch all you have to do is put a pic in the folder and it will be added to the list.

//this function goes through the defined directory and makes a list of all the files
function parse_dir($dir,$level){
	$dp=opendir($dir); //opens the directory for reading
	while (false!=($file=readdir($dp))){  //runs until no more files
		if ($file!="." && $file!=".." && $file!=".htaccess"){  //so you don't get all the default folders
			$countervar=$countervar+1;  //just a counter for numbering the path names
			if (is_dir($dir."/".$file)) parse_dir  //recurses the subdirectories
			else print "&path".$countervar."=".$dir."/".$file;  //pieces together something flash can read

$start_dir="pathToMyPics";  //put the name of the folder with all the pics here


The above php will output something like this
call the php in flash( loadVariables(“fileListPHP.php”) ) and viola you get easy to use paths to all you pictures.

You saed my day…thaaaanx a lot, your code is working for me.

I had one more problem to be solved using text file…I need to control the background color of the flash file using external text file…ypu know the solution plz reply.

Thanx again

You would add a var in the text file with a hex color value (the color you want) and then call setRGB on a dummy “background” movieclip with, of course, the hex color you loaded in.

just like Freddythunder and Dunga said, you can make a movieclip on the bottom layer as your movie background. named it “bground”.

then, in your notepad, type in all color you want. ex. color1 is red, color2 is green etc
"color1=0xFF0000&color2=0x009900&color3=0xFFFF00" (without quote)

we’ll change “bground” with 3 buttons (named “bt1”, “bt2”, “bt3”) to the colors. in flash, make your buttons.

same as actionscript for loading photo through ext txt, here’s AS in frame:

url = new LoadVars(); 
url.onLoad = function() {

function nuColor(col) {
meColor=new Color(bground);



that’s what i know, since i’m not a flash master

Neither am I, but your code looks like it would work, exept that you left off a bracket on the onLoad bit.