The quick answer is simple: create an SWC component from your Flash CS5 fla file and just add them to your FlashDevelop project. If you do everything well, the integration will work very fine.
The long and detailed answer is a bit more intersting. Suppose, that the integration means the SWC component will communicate with the other parts of the project. The component takes input datas and it gives back some output datas. You don’t just add your fla file like a MovieClip to the stage of the FlashDevelop project, it works with datas and it produces datas. But even the displaying of the whole fla file is not always very easy in FlashDevelop, even if you created an SWC component from the fla file. You can display any exported symbols or classes from the library of the fla project, but what about the main timeline and the scenes? How can you display these things?
These two things – the communication and the instanciating – make the problem of the integration more difficult. Adding a document class to your fla file is likely an elegant solution, you just create one big class from your fla file, then you save it as an SWC component and voila – you can use it in FlashDevelop like any other class.
I created a demo, a tutorial about how to convert your fla files to easily reusable SWC components. Of course it is just my solution, I don’t know, maybe there is an easier way to use fla files via FlashDevelop. However, this solution works well and maybe it inspires you to find a better solution for the integration.
Okay, so you have your own fla project and you want to create an easily reusable swc component from that. (In the tutorial,
original_game.fla is the starting fla file.) Just follow these steps:
- [Coding stlye]You have to follow four simple rules which guarantee that you will be able to create one big class from your fla project. These four rules are:
- Use only one scene.
- Use just the frame one on the main timeline of the scene.
- The frame scirpt of frame one (which is the only one frame) must be exactly “stop();”. Don’t add other scripts to the frame one.
- There must be only one symbol on the frame one, it is the so-called top-level object, what contains anything else. Use the timeline of the top-level object, put as much scripts on its frames as you want to, put as much symbols on its frames as you wish but there can be only one top level symbol. (Note:
Gameis the top level symbol in the
- [Set the document class] After you finished your fla file and it works well, you have to set the document class. I created a template, take a look at the
/sources/MainSecond.as. Just copy that script and use it as your document class.
- [Set the input/output] You can read the input datas and you can return the output datas through the methods of MainSecond.as. Just call the
MainEnd(obj)methods. (Look at the source code of MainSecond.) Extend your scripts with these methods.
- [Fix the disambiguity of the entry point]If you use an ordinary fla file with more scenes and various scripts and document class, then the identification of the entry point is not very easy. (Nor with decompilation, I tried it). You have to use just only one entry point at the constructor of the document class, so:
- Remove the instance of the top level symbol and the script from the frame one, delete everything. The frame one must be totally empty. Every scripts and symbols (and the top level symbol) are now in the libary.
- Export the top level symbol, because the export allows to use it in outer script files like in the document class.
- Create an instance of the top level symbol in the constructor of the document class and place the object to the stage.
- [Create the swc file] The last step is the easiest. Open the ”File/Publish settings”, mark the ”Export SWC” box and click on the Publish button!
I created a pdf file (the tutorial.pdf) with several screenshots about these steps and I performed these steps on the “original_game.fla” (I integrated it into a FlashDevelop project). After than I compressed all of these files into the tutorial.zip. You can download it, you can open it, you can enjoy it, if you want to. I hope you find my tutorial at least a bit helpful.