Flash: Create background pattern in Flash 8
September 27th, 2005 by LuisQuick example of how to create a tiled bitmap in Flash 8 using MovieClip.beginBitmapFill method instead of using duplicated movieclips.
SWF sample:
[flash]http://www.blog.lessrain.com/wp-content/upload/tilebackground2.swf,400,200[/flash]
Actionscript:
- import flash.display.BitmapData;
- var pattern:BitmapData = BitmapData.loadBitmap("img_105");
- function createTiles():Void {
- with (_level0) {
- beginBitmapFill(pattern);
- moveTo(0, 0);
- lineTo(Stage.width, 0);
- lineTo(Stage.width, Stage.height);
- lineTo(0, Stage.height);
- lineTo(0, 0);
- endFill();
- }
- }
- createTiles();
Related Entries:


September 27th, 2005 at 4:36 pm
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.
Dedé
September 27th, 2005 at 4:46 pm
Please forgive me! I was publishin with AS1.0… LOL… sorry about that!
It worked like a charm… GREAT!!!
Many thanks,
Dedé
September 27th, 2005 at 10:52 pm
Beautiful. Very helpful post, thanks.
October 12th, 2005 at 9:54 am
[…] 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 […]
October 31st, 2005 at 11:58 pm
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
thx!
November 28th, 2005 at 7:47 am
IT DOESN’T WORK FOR ME
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?
December 6th, 2005 at 4:13 pm
make sure that you set the bmp in your libary for export for actionscript. works beautifully
January 4th, 2006 at 4:09 am
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.
thanks!
January 4th, 2006 at 4:19 am
nevermind, i figured it out in the publish settings, i’m a jackass. thank you!
February 2nd, 2006 at 4:48 am
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!
April 3rd, 2006 at 9:05 pm
Yes, just use this pattern:
BitmapDataObject.draw(VectorMovieClip);
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.
August 18th, 2006 at 5:49 pm
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.
March 24th, 2007 at 12:14 am
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
Thanks
Jerdison
April 10th, 2007 at 9:49 am
enjoi and scott
this may help (at least for me was enough)
http://livedocs.adobe.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00001959.html
July 19th, 2007 at 9:28 pm
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.
September 19th, 2007 at 10:54 pm
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?
September 20th, 2007 at 12:16 am
Never mind! I found the answer. Here’s a page explaining how to tile any movie clip or whatever you desire:
http://www.kirupa.com/developer/mx2004/duplicatebackground.htm
January 14th, 2011 at 9:59 pm
I found a free Tile Background Using AS3, you can find it at http://www.as3tutorial.com tutorials page.