Tiling FCS3 Library Symbols in Flex
Something I’ve had to do a couple times in the past, so here is one way to do it. Suppose you need to tile a MovieClip symbol in a FCS3 library (perhaps a composite of vector and bitmap graphics) inside some DisplayObject in a Class used in a Flex app.
In FCS3, set the linkage properties to a Class of something like com.myclient.myprojectname.symbols.TileableSymbol with a Base Class of flash.display.MovieClip. Set your friendly neighborhood publish properties to export a .SWC. Publish the file to a symbols or libs or some other suitable folder in your Flex project.
In the Flex project properties, select Actionscript Build Path | Library Path tab and make sure the folder containing the published .SWC is selected by clicking Add SWC Folder. You should see the exported .SWC; make sure the Framework linkage is ‘Merged into code’.
You may need to clean the project in order for the symbol to be visible. In the script for whatever Class is responsible for tiling the symbol, import com.myclient.myprojectname.symbols.TileableSymbol (or whatever more suitable name you choose).
Suppose you have an instance of BitmapData called _bitmapData. The code would look something like
var myTile:TileableSymbol = new TileableSymbol();
_bitmapData = new BitmapData(_tileWidth, _tileHeight);
_bitmapData.draw(myTile, null, null, BlendMode.NORMAL);
var g:Grapics = myContainer.graphics;
g.beginBitmapFill(_bitmapData, null, true, true);
g.drawRect(0, 0, widthToTile, heightToTile);
If the tileable symbol is nothing more than a standalone bitmap in the library, the process is easier. If there is sufficient interest, I may create a downloadable example of both cases, especially as there are some variations of this approach to illustrate.