Jump to content

Background Color From An Xml File


Hooch
 Share

Recommended Posts

Hello all, I have Googled this a couple ways and have found absolutely nothing.I simply want a flash file to get it's background color from an xml file.Eventually I will change the xml file to a php file that gets the color froma database. Then I will have a member pick their own color scheme. Thank you.

Link to comment
Share on other sites

Hello all, I have Googled this a couple ways and have found absolutely nothing.I simply want a flash file to get it's background color from an xml file.Eventually I will change the xml file to a php file that gets the color froma database. Then I will have a member pick their own color scheme. Thank you.
I don't think you can change the background of your Flash movie but you can use a different colored rectangle as the background.This is how you read a color from an XML file:
var xmlLoader:URLLoader = new URLLoader( new URLRequest("bgcolor.xml") );xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);function xmlLoaded(e:Event):void{    var bgcolor:XML = XML(xmlLoader.data);    var bg:Shape = new Shape();    bg.graphics.beignFill(uint(bgcolor.color));    bg.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);    bg.graphics.endFill();    addChildAt(bg, 0);}

bgcolor.xml is your XML file which contains the hexadecimal color code inside <color></color> tags.

Link to comment
Share on other sites

No, the rectangle will be a Shape object. It takes up less memory and will do the job. It will be generated by the code I wrote in my previous post (I have not tried executing it so let me know if it's erroneous); you won't have to draw your own rectangle.

Link to comment
Share on other sites

The xml code needs tweakinghere's what I have.

<?xml version="1.0" encoding="utf-8"?><color bgcolor="0xff6600"></color>

I have tried the following with no luck either

<?xml version="1.0" encoding="utf-8"?><color>#FF6600</color>

Edited by Hooch
Link to comment
Share on other sites

  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...