So I started to open the books for AS3 . I feel like AS2 is starting to die….
Anyway just like the title says. I need help. Can someone give me an example please on how to change a movieclip color via xml.
I’ve search and can’t seem to find any help besides only for AS2
Thanks 
Tim
- Author was Featured
- Sold between 50 000 and 100 000 dollars
- Author had a Free File of the Month
- Bought between 1 and 9 items
- Exclusive Author
- Europe
- Has been a member for 3-4 years
- Referred between 10 and 49 users
- Repeatedly Helped protect Envato Marketplaces against copyright violations
Use ColorTransform:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/geom/ColorTransform.html
<color>0x00ff00</color> var myColor:ColorTransform = new ColorTransform(); myColor.color = uint(xml.color); myMovieClip.transform.colorTransform = myColor;
Sweeeeeeeeeeeeet
Works thanks allot!
Code:
import flash.geom.ColorTransform;
var myXML:XML;
var myLoader:URLLoader = new URLLoader();
myLoader.load(new URLRequest("custom_color.xml"));
myLoader.addEventListener(Event.COMPLETE, processXML);
function processXML(e:Event):void {
myXML = new XML(e.target.data);
trace(myXML);
var myColor:ColorTransform = new ColorTransform();
myColor.color = uint(myXML);
custom_color_box_mc.transform.colorTransform = myColor;
}
or you can use Color
<color>0x00ff00</color> import fl.motion.Color; var myColor:Color = new Color(); myColor.color = uint(xml.color); myMovieClip.transform.colorTransform = myColor;Color extends ColorTransform , you can set the brightness …
Or just use one of the tween libraries. Here using Tweener with just 1 line:
Tweener.addTween(mcName,{_color:uint("0x" + xml.mcColor)});
Also using this method the buyer doesn’t have to enter the “0x” part in the xml, which makes things more simple.
- Author had a Free File of the Month
- Microlancer Beta Tester
- Beta Tester
- Contributed a Tutorial to a Tuts+ Site
- Won a Competition
- Repeatedly Helped protect Envato Marketplaces against copyright violations
- Item was Featured
- Author was Featured
- Referred between 1 and 9 users
just remember if your movie clip is just graphic if you make your shape in pure AS you don’t need all this mambo jumbo stuff.
Then you can apply your color directly via xml with no tween,colorTransform bla bla,work affective make it light 
Thats awesome! Thanks 
I must say a few years ago I couldn’t stand Actionscript but ever since I found this community its been such an awesome experience learning it. I’m loving it. You guys rock!
Thanks again everyone!
Tim
Hey Everyone!
I’m new to flash and really learned on a older version of flash. Actionscript has proven to be more then I know, but I am learning. This is a test project I am working on and really only have two issues left. This being on of them. So let me explain my problem…
I have an XML sheet being referenced into flash. In the XML sheet I have a series of inputs: Shops 1 – Unit 101 4,204 TBD Available Shops 1 – Unit 102 2,004 Revol Nails – Spa LeasedWhat I am trying to do is make the movie clip button change color based on the , ie. either Available or Leased located in the XML file
These variables will change from Available to Leased from time to time, and I would like to create an If/then statement to determine the color. I would like the XML file to alter the color of the movie clip instead of having to edit the flash file every time there is a change.
Is this possible? Does this require anything extra to accomplish? Below is the code that I am currently using:
Here is the code that I have thus far, with a piece of code that I found online that addresses “changeButtonColor”. I’m not sure how to implement the code though.
Any help is appreciated. Thank you.
s11.addEventListener (MouseEvent.CLICK, onClick); s11.addEventListener(MouseEvent.ROLL_OVER, mcOver); s11.addEventListener(MouseEvent.ROLL_OUT, mcOut);
s11.buttonMode = true;
function showXML(e:Event){
function changeButtonColor(available:Boolean):void {
if(available){
// change colour to blue
} else {
// change colour to red
}
}
XML .ignoreWhitespace = true; var bldg:XML = new XML ; var i:Number;
var myText:String = new String(); textField.multiline=true; textField.wordWrap=true; textField.text = myText; for (i=0; i < bldg.S11.length(); i++) { myText += “” + bldg.S11[i].Title + “
”;
myText += “Square Footage: ” + bldg.S11[i].SF + “
”;
myText += “Tenant: ” + bldg.S11[i].Tenant + “
”;
myText += “Status: ” + bldg.S11[i].Status + “

