Search code examples
actionscript-3buttonflash-cs4

Access SimpleButton children


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?


Solution

  • 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.