Flash: Create a Video background pattern in Flash 8

October 12th, 2005 by Luis

Someone ask me about creating a background pattern with video, which it is not a big deal since we can use MovieClip.beginBitmapFill method in order to fill a drawing area with a bitmap image or like in this case with a video by using the BitmapData.draw method.

SWF sample (You need a webcam):

[flash]http://www.blog.lessrain.com/wp-content/upload/tilebackground3.swf,400,200[/flash]

Actionscript:
  1. import flash.display.BitmapData;
  2.  
  3. var w:Number = Stage.width;
  4. var h:Number = Stage.height;
  5. var columns:Number = 6;
  6. var rows:Number = 3;
  7.  
  8. this.attachMovie("videoContainer", "myVideoContainer", 10);
  9. var my_cam:Camera = Camera.get();
  10.  
  11. myVideoContainer.video.attachVideo(my_cam);
  12. myVideoContainer.video._width = Math.round(w/columns);
  13. myVideoContainer.video._height =Math.round(h/rows);
  14.  
  15. var pattern:BitmapData = new BitmapData(myVideoContainer.video._width, myVideoContainer.video._height, false, 0);
  16.  
  17. function createTiles():Void {
  18.     with (_level0) {
  19.         beginBitmapFill(pattern);
  20.         moveTo(0, 0);
  21.         lineTo(w, 0);
  22.         lineTo(w, h);
  23.         lineTo(0, h);
  24.         lineTo(0, 0);
  25.         endFill();
  26.     }
  27. }
  28.  
  29. createTiles();
  30.  
  31. this.onEnterFrame=function() {
  32.     pattern.draw(myVideoContainer);
  33. }


5 Responses to “Flash: Create a Video background pattern in Flash 8”

  1. Garry Duco Says:

    Cool

  2. Video Background » Heidsite: Video: Background & Tips Says:

    […] international television. Versatile programming products on digital video. lessrain blog Blog Archive Flash: Create a Video background Flash: Create a Video background pattern […]

  3. lessrain blog » Blog Archive » Flash: FLV resources Says:

    […] Articles. Related entries: - Flash: About Cue points - Flash: Standalone Video Player - Flash: Create a Video background pattern in Flash 8 - Flash: Video Articles - Flash: How to de-interlace vide […]

  4. kate Says:

    i like flash ,i like video, sounds your method is good, but i also have one, use tools to find at http://www.yaodownload.com/video-design/video/ , do your movie and flash by yourself!

  5. Johan Says:

    Is it possible to use a real video and use it as a background(if the viewer had the bandwith for it)? Lets say you had a 10 sec video loop? Could you have a menu on top of it with text and stuff?

Leave a Reply