Jump to content
Hooch

Background Color From An Xml File

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.

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...