320 posts
  • Has been part of the Envato Community for over 7 years
  • Has collected 100+ items on Envato Market
  • Located in 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

1677 posts Envato Elite Author
  • Has referred 10+ members
  • Has sold $125,000+ on Envato Market
  • Has collected 1+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+6 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
  • Has been part of the Envato Community for over 7 years
  • Has collected 100+ items on Envato Market
  • Located in 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
  • Has referred 10+ members
  • Has sold $40,000+ on Envato Market
  • Has collected 50+ items on Envato Market
  • Had an item featured in an Envato Bundle
+4 more
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
  • Has been part of the Envato Community for over 5 years
  • Has referred 10+ members
  • Has sold $10,000+ on Envato Market
  • Has collected 10+ items on Envato Market
+4 more
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
  • Has referred 1+ members
  • Has sold $5,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Contributed a free file of the month
+9 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
  • Has been part of the Envato Community for over 6 years
  • Has referred 1+ members
  • Has sold $5,000+ on Envato Market
  • Located in Brazil
+3 more
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
  • Has been part of the Envato Community for over 7 years
  • Has collected 100+ items on Envato Market
  • Located in 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 part of the Envato Community for over 3 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; }

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by