Importing Spritesheets in Flash to Export them as MovieClips in SWC Libraries

There are several reasons we might have to export resources from flash:

  • to create libraries to reuse them in other flash projects
  • to use Flash Builder or Flash Develop for writing code and Flash to create graphical assets
  • to use swc libraries in haxe projects

Lets take the following sprite:

player-plane

1. Create a new flash project save it and import the following image in library or simply drag and drop it in flash. In both the cases the image will appear in the library and an image:

aeroplane-sprite

2. Using the Rectangle Primitive Tool draw a rectangle of the dimensions of one frame in the sprite:

rectangle0primitive-tool

3. Now make sure the rectangle has no border and set the fill to Bitmap Fill and select the imported image to fill. In following picture the rectangle is a little bit larger than the actual frame to get an idea of what bitmap fill means:

bitmap-fill

4. Now right click on the rectangle and convert it to Symbol:

convert-to-symbol

… and in the newly open dialog set the name of the MovieClip object. In order to export the plane resource, make sure the export to actionscript is checked.

plane-res

5. Double click on the created MovieClip and add 3 more Keyframes. Now we have to change the rectangle in the first and third frames so it will result in an animated MovieClip.  To do so select the Gradient Transform Tool:

GradientTransform

 

… and re-position the bitmap fill so the first frame from the spreadsheet is displayed. Repeat the operation for the third frame so in the end the MovieClip will look like this:

PlaneSymbol

6 .Open File > Project Settings… and check the SWC option so the classes marked to be exported to AS at point 3 will be exported in the swc.

Export

 

Leave a Reply

Your email address will not be published. Required fields are marked *