I’m working on allowing a user to change the color of a clip art object. They start out externally as transparent PNG’s. But I can prepare them in another format if necessary. My question is, is there any method for changing the color of the object from black to a selected color?
I tried masking a it with a rectangle of a different color, but the full color rectangle shows. Can you mask a Bitmap object with loaded content? Is there another way for this to work?
Thanks for your time.
My code is below, based on what I read at http://livedocs.adobe.com/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00000168.html
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Loader;
import flash.display.Sprite;
import flash.events.*;
import flash.geom.Point;
import flash.geom.Rectangle;
import flash.net.URLRequest;
import flash.display.Shape;
var request:URLRequest = new URLRequest("http://localhost/mysite/clipart/1.png");
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
loader.load(request);
function completeHandler(event:Event):void {
var loader:Loader = Loader(event.target.loader);
var image:Bitmap = Bitmap(loader.content);
var square:Sprite = new Sprite();
square.graphics.lineStyle(1, 0x000000);
square.graphics.beginFill(0xff0000);
square.graphics.drawRect(0, 0, image.width, image.height);
square.graphics.endFill();
addChild(image);
addChild(square);
square.mask = image;
}