# Can I use jpg as mask?

**URL:** <https://forum.kirupa.com/t/can-i-use-jpg-as-mask/326563>\
**Category:** flash\
**Created:** [December 24, 2011, 2:10pm UTC](https://forum.kirupa.com/t/can-i-use-jpg-as-mask/326563 "2011-12-24T14:10:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![zeeto](https://avatars.discourse-cdn.com/v4/letter/z/e274bd/32.png) [@zeeto](https://forum.kirupa.com/u/zeeto)\
**Post date:** [December 24, 2011, 2:10pm UTC](https://forum.kirupa.com/t/can-i-use-jpg-as-mask/326563/1 "2011-12-24T14:10:44Z")

</div>

Hi,

I wanted to put on the stage a png file with some transparent areas, unfortunately it weight too much.  
So instead I thought I’ll create a shape object and use jpeg image as it’s mask…

This is my code:

```auto
package {

 import flash.display.Bitmap;
 
 import flash.display.Shape;
 import flash.display.MovieClip;
 
 import flash.display.Loader;
 import flash.net.URLRequest;
 
 import flash.events.Event;
 
 public class Map extends MovieClip {
  
  private var color :Shape = new Shape;
  private var map :Bitmap = new Bitmap;
  private var loader :Loader = new Loader();   
  
  public function Map():void {
   
   color.graphics.beginFill(0xFF0000, 1);
   color.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
   color.graphics.endFill();
   
   loader.load(new URLRequest("map.jpg"));
   loader.contentLoaderInfo.addEventListener(Event.COMPLETE, draw);
  }
  
  private function draw(e:Event):void {
   
   loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, draw);
   
   map = loader.content as Bitmap;
   
   addChild(color);
   color.mask = map;
  }
 }
}

```

And it doesn’t work, can I use jpeg images to mask the shape at all?

Thx  
Z
