views:

407

answers:

2

I have a Flash .fla file that has SimpleButton. That SimpleButton is basically a button-like shape, with an icon on it (say it's a "pause" sybol). I want to change the color of that icon programmatically, but I can't seem to access it from AS.

I've selected the icon, and did "convert to symbol", and gave it an instance name. This has worked for most other things I've wanted to access, but it fails for this purpose. I've looked for it in the debugger, but I just can't access the object.

So, what's the way to do this?

+1  A: 

If you are looking for the states of the button you can find them here: SimpleButton.upState, SimpleButton.overState, SimpleButton.downState.

You could change the colour by manipulating the coulorTransform of the transform property. See here: http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/geom/ColorTransform.html

EDIT: To change only the background colour, the best solution would properly be to simply have the background as DisplayObject contained in the states, and then change that. But you would have to listen for state changes, to keep the colour changes.

Alternativly you might be able to find a component to do just that if your needs are generic enough.

Lillemanden
Yes, I've found all that, and that sort of works. But, unfortunately, they don't allow me to change just a section of the button.
Sietse
Ok, I updated my answer. But there is not really an easy way of doing.
Lillemanden
A: 

The issue here is that SimpleButton is really not a class made for that type of behavior. I would recommend writing your own quick little class that emulates the behavior of SimpleButton but allows you to change the look of the children. Writing your own classes like this in a global classpath will make your future projects easier too.

Jesse
I'm working on something like this as well, and it's not a quick little class. The built-in SimpleButton handles a lot of edge cases that will be easy to miss in your own code.
Scott Bilas