Someone on a Flash mailing list asked how to create an html-like tiled background out of a .gif. Here's a very quick little tutorial on how to do that.
- Import the .gif file (File -> Import)
- Click on the image, and press F8 (same as Insert -> Convert to Symbol)
- Name the symbol "tile" (the symbol name is actually irrelevant, name it what you like), click the "MovieClip" radio button, and click the top left square next to "Registration." This places the origin in the top left corner. Click OK.
- Select the tile Movie Clip on the stage and give it an instance name of "tile0_0_mc" (unlike the symbol name which you could make up yourself, make sure you use this as the instance name)
- Set the coordinates of the movie clip to be at 0,0 (ctrl+alt+1, ctrl+alt+4 are the shortcut keys for this, or use the properties panel to enter 0 as the x and y coordinates)
- Copy and paste this script on the timeline:
for (var x = 0; x < Stage.width; x += tile0_0_mc._width) { for (var y = 0; y < Stage.height; y += tile0_0_mc._height) { targ = "tile" + (x/tile0_0_mc._width) + "_" + (y/tile0_0_mc._height) + "_mc"; // the if statement prevents us from having two tile0_0_mc's on the stage if (x != 0 || y != 0) { duplicateMovieClip(_root.tile0_0_mc, targ, ++_global.depth); _root[targ]._x = x; _root[targ]._y = y; } } } - Export the movie, and see your .gif become a tiled background!

Hello,
that seems like a great script, but i just don't get it to work.
Could you please post a .fla file?
Thanks in advance!
Janne.
ah, just found out it isn't working when you export as Flash 7. Works great in 6 though!
to tile a background, you can also break apart the gif, then use the eyedropper tool to copy the pattern. Then just draw a rectangle the size of the stage and fill w/patter.
The code broke for Flash Player 7 because I was attempting to use a "depth" variable before it was defined. When this code was written, Flash Player 6 was the latest and greatest, and everything worked just fine. A quick modification for the code to work with the newest version of the Flash Player:
var depth = 0;
for (var x = 0; x < Stage.width; x += tile0_0_mc._width) {
for (var y = 0; y < Stage.height; y += tile0_0_mc._height) {
targ = "tile" + (x/tile0_0_mc._width) + "_" + (y/tile0_0_mc._height) + "_mc";
// the if statement prevents us from having two tile0_0_mc's on the stage
if (x != 0 || y != 0) {
tile0_0_mc.duplicateMovieClip(targ, ++depth);
this[targ]._x = x;
this[targ]._y = y;
}
}
}
nice one thanks I have been looking for something like this for a couple of hours =)