Skip navigation
Alphonse23
Currently Being Moderated

bitmap as mask

Aug 6, 2012 1:21 AM

I have a few imported images in my library I'd like to use as a mask to fit over a video but I can't get it to work. Here's how it works so far. The imported image is a photoshop .psd with some transparent layers.

 

import flash.display.Sprite;

import flash.media.Video;

import flash.display.MovieClip;

 

public class Main extends Sprite {

public function Main() {

     private var video:Video = new Video();

     private var dot:MovieClip = new Symbol1();

    

    

     video.width = 160;

     video.height = 90;

 

     video.x = 443; //Video position

     video.y = 190;

     addChild(video); //Add video to stage

    

     dot.x = video.x;

     dot.y = video.y;

     addChild(dot);

 

     video.mask = dot;

}

}

 

This doesn't work. The video just gets masked by the whole image, and not the shape with the trasparent layer.

 

So I figure I'd have to convert the psd to a bitmap, cause it sounds like you can only use bitmaps. So I just draged the psd image into flash to get a bitmapdata file in my library. But it still doesn't work. Here's the new code:

 

private var dot:BitmapData = new Bitmap6;

 

public function main {

          video.x = 443; //Video position

                                        video.y = 190;

                                        addChild(video); //Add video to stage

 

                                        dot.x = video.x;

                                        dot.y = video.y;

                                        addChild(dot);

 

                                        video.mask = dot;

}

 

but now I get these compiler errors:

 

 


1119: Access of possibly undefined property x through a reference with static type flash.display:BitmapData.

1119: Access of possibly undefined property y through a reference with static type flash.display:BitmapData.

1067: Implicit coercion of a value of type flash.display:BitmapData to an unrelated type flash.display:DisplayObject.

1067: Implicit coercion of a value of type flash.display:BitmapData to an unrelated type flash.display:DisplayObject.

 

 

So now I'm not sure what to do. Can anybody help me out?

Thanks, if anyone can help.

 
Replies

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points