320 posts
  • Bought between 100 and 499 items
  • Has been a member for 7-8 years
  • United States
timmylogue says

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 :D

Tim

1676 posts Envato Elite Author
  • Elite Author
  • Sold between 100 000 and 250 000 dollars
  • Author had a Free File of the Month
  • Exclusive Author
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Europe
  • Has been a member for 4-5 years
  • Referred between 10 and 49 users
+1 more
Tean says

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;

320 posts
  • Bought between 100 and 499 items
  • Has been a member for 7-8 years
  • United States
timmylogue says

Sweeeeeeeeeeeeet :D 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;

}

1161 posts
  • Author had a File in an Envato Bundle
  • Has been a member for 5-6 years
  • Sold between 50 000 and 100 000 dollars
  • Exclusive Author
  • Referred between 10 and 49 users
  • Bought between 50 and 99 items
FlashTang says

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 …
567 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 5-6 years
  • Ireland
  • Referred between 10 and 49 users
  • Sold between 10 000 and 50 000 dollars
iamdok says

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.

1612 posts
  • Author had a Free File of the Month
  • Envato Studio (Microlancer) Beta Tester
  • Beta Tester
  • Contributed a Tutorial to a Tuts+ Site
  • Won a Competition
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Referred between 1 and 9 users
+5 more
DaniMun says

In addition to Donagh’s advice, I’d suggest you give Greensock’s outstanding TweenMax tween library a try :)

TweenMax.to(mcName, 1, {tint:uint("0x" + xml.mcColor)});

As a matter of fact, you can do so much more with TweenMax :) Scroll down to the Plugins section and check them out ;)

4140 posts
  • Bought between 1 and 9 items
  • Brazil
  • Exclusive Author
  • Has been a member for 6-7 years
  • Referred between 1 and 9 users
  • Sold between 5 000 and 10 000 dollars
tsafi says

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 :P

320 posts
  • Bought between 100 and 499 items
  • Has been a member for 7-8 years
  • United States
timmylogue says

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

1 post
  • Has been a member for 3-4 years
AndyJChew says

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 Leased

What 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 + “

”; } textField.htmlText = myText; }
by
by
by
by
by
by