i want to ask, how to change only fill color of an instance on the stage - i can do it by using ColorTransform object, but it changes color of the whole instance, not just the fill. I want to change only the fill color, not the stroke color. can anybody help me?
this is my code:
function paint(){
var myColorTransform:ColorTransform = new ColorTransform();
myColorTransform.color = someColorNumber;
coloredObject.transform.colorTransform = myColorTransform;
}
I know this is a bit late to the game, but I was having this same issue and fixed it a bit differently. It may not be of any help since it will only work in limited circumstances*, but I started with my shape being filled white & stroked black. That way you can apply a color transform with RGB multipliers, to fade the white down to your desired colour leaving the black border intact. So to make your object red (with black border) use:
Or for Stack Overflow orange (still with black border):
*It'll only work if you just want a single colour with a black border.
If you are targeting FP10, and you want a simple filter like what you tried with ColorTransform, you could write a PixelBlender Kernel to take an 2 arguments of colors (one for source, one for destination), match the pixel with the source color, and swap them for the destination; something like this:
Remembers why he hates the PixelBlender IDE
EDIT: Remember that this will not play well with anti-aliasing, but if you are using stage.quality = "low", it won't matter.
To add use it in as3, try this (stolen from http://scriptplayground.com/tutorials/as/Flash-CS4-and-Pixel-Bender-Overview/, so you will need to change a few lines of code):
Sorry for making your eyes bleed! I think that is my longest answer yet!
This cant be done once you've drawn a shape as action script has no way of determining what is a stroke and what is a fill.
You have a couple of options.
Separate your fill and stroke into separate movie clips and set the color transform to only apply to the fill.
or
If it's a simple shape, draw it using the Graphics object where you can specify fill colours and stroke colours.
Likely hood is, and my preferred method, would be the first options as the shape is likely to be complex and leaving it in the fla gives greater control for a designer being able to change it rather than a developer. It's a little more work though and slightly more complex.