# "Floodfilling" externally loaded clip art with a mask?

**URL:** <https://forum.kirupa.com/t/floodfilling-externally-loaded-clip-art-with-a-mask/270907>\
**Category:** flash\
**Created:** [September 16, 2008, 3:09am UTC](https://forum.kirupa.com/t/floodfilling-externally-loaded-clip-art-with-a-mask/270907 "2008-09-16T03:09:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![cactusphone](https://avatars.discourse-cdn.com/v4/letter/c/9d8465/32.png) [@cactusphone](https://forum.kirupa.com/u/cactusphone)\
**Post date:** [September 16, 2008, 3:09am UTC](https://forum.kirupa.com/t/floodfilling-externally-loaded-clip-art-with-a-mask/270907/1 "2008-09-16T03:09:56Z")

</div>

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](http://livedocs.adobe.com/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00000168.html)

```auto

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;			
		
}

```
