Flash: Create background pattern in Flash 8

September 27th, 2005 by Luis

Quick example of how to create a tiled bitmap in Flash 8 using MovieClip.beginBitmapFill method instead of using duplicated movieclips.

SWF sample:


  1. import flash.display.BitmapData;
  2. var pattern:BitmapData = BitmapData.loadBitmap("img_105");
  3. function createTiles():Void {
  5.         with (_level0) {
  7.                 beginBitmapFill(pattern);
  8.                 moveTo(0, 0);
  9.                 lineTo(Stage.width, 0);
  10.                 lineTo(Stage.width, Stage.height);
  11.                 lineTo(0, Stage.height);
  12.                 lineTo(0, 0);
  13.                 endFill();
  14.         }
  16. }
  18. createTiles();

Related Entries:

18 Responses to “Flash: Create background pattern in Flash 8”

  1. Dedé Says:

    Very nice, but I coudnt implement it :( I had cut and paste the code and got this 3 errors in the Output:

    Error Scene=Scene 1, layer=Action Layer, frame=1:Line 1: Syntax error.
    import flash.display.BitmapData;

    Error Scene=Scene 1, layer=Action Layer, frame=1:Line 3: ‘{’ expected
    function createTiles():Void {

    Error Scene=Scene 1, layer=Action Layer, frame=1:Line 16: Unexpected ‘}’ encountered

    Total ActionScript Errors: 3 Reported Errors: 3

    Note that I have put the class in the right place, the image linked in the library as well. So, what am I doing wrong?

    Thanks in advance.


  2. Dedé Says:

    Please forgive me! I was publishin with AS1.0… LOL… sorry about that!
    It worked like a charm… GREAT!!!

    Many thanks,


  3. Mike Britton Says:

    Beautiful. Very helpful post, thanks.

  4. lessrain blog » Blog Archive » Flash: Create a Video background pattern in Flash 8 Says:

    […] 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 i […]

  5. enjoi Says:

    Doesn’t want to work :( where do I have to place the bitmap ? in my library ?
    I placed it in my library gave it a unique name etc.. replaced the name in the script doesn’t seem to work, just placed the actionscript in a Actions layer…
    can anyone sent me an example ?
    joeriverdeyen at gmail dot com

  6. Scott Says:


    I copied to code into a virgin document and imported a simple 20×20 bitmap as a test into the library.

    It doesnt show a thing.

    Any thoughts?

  7. ashley98860615 Says:

    make sure that you set the bmp in your libary for export for actionscript. works beautifully

  8. melissa Says:

    does anyone know how to make your flash document have a transparent background? i want to use a background in my HTML doc (that i am incorporating the flash into) and i want it to match with my flash document.


  9. melissa Says:

    nevermind, i figured it out in the publish settings, i’m a jackass. thank you!

  10. Bootchmonkey Says:

    Is there anyway to “tile” a vector drawing, perhaps a movie clip? Or does all the definition for the tiles area have to be programed in. So, let’s say I have a movie clip which is a drawn star (not programmed in through coordinates) and want to change to color of it by using a bitmap instead of the setRGB function. Can I do this?

    Thank you in advance!

  11. Jason Says:

    Yes, just use this pattern:

    This will transfer the bitmap representation of the vector (movie) into the bitmap object.

    You can change the colors later by changing the pixels in the bitmap, or recreating the bitmap after changing the source vector movieclip.

  12. strain Says:

    Looks very promising, I have a little question though, is there any way to make that whole pattern into a controllable movieclip? Say if i want to fade out or color it or similar. :)

  13. drdave17 Says:

    I tried param name=”wmode” value=”transparent” parameter and my flash background is still showing.

    I want to make it transparent.

    I am using Flash 8


  14. Adrian Says:

    enjoi and scott

    this may help (at least for me was enough)


  15. tuva Says:

    import your bitmap. When the bitmap is in the library right click on it and go to properties. Click Export for actionscript. The place the code on its own layer. Make sure you publish for Flash 8.

  16. QA Says:

    Pardon my noob-ness. I like how bitmaps can be treated like fills in Flash and I want to do the same with vector artwork. I want to make a tiling vector background. Can anyone please advise?

  17. QA Says:

    Never mind! I found the answer. Here’s a page explaining how to tile any movie clip or whatever you desire:


  18. ZREN Says:

    I found a free Tile Background Using AS3, you can find it at http://www.as3tutorial.com tutorials page.

Leave a Reply