In a previous post, I talked about how you can use SWC Importation to use Flex and Flash together. I realize that I never said why you should be using this. Let me tell you about the advantages (as well as a couple disadvantages) and why it’s a no-brainer if you’re making games in flash and have decent programming skills.
The Good Points
You will be less reliant on .FLA files
There are big problems with Fla files. Unless you shell out for an expensive Adobe tool, Fla files are not mergable. This means that you can’t have two people working on a fla file at the same time – plus everything has to be in one fla. ( If you’re using source control, you need to make sure your fla files are locked) With SWC importation, you can break up your art into as many fla files as you want. You could have one for your main character, one for your enemies, one for the UI. However you want. This keeps your artists from being blocked while someone else is working in your main Fla file.
Greatly reduced compile times
When you compile your game in the Flash IDE, it builds all the assets that you have everytime you do it. The amount of time it takes may not be so bad when you first start, but what happens as you keep adding assets? Each one you add will slow you down! The IDE likes to do dumb things as well. If you have a compile error in your code, the IDE will still build the assets and then launch your game even though it’s not going to work.
When using Flex, you don’t have to rebuild assets every time, and you only compile the code that has changed. I can’t stress how much time is lost waiting for things to compile. If you don’t believe me, time it yourself – then do it again once you start to add a lot of assets.
You keep the great parts of the flash IDE
The Flash IDE is one of the best WYSIWYG editors and animation tools out there. ScaleForm, which makes UI tools used in games like Mass Effect, uses the Flash IDE for this reason. Using Flex and Flash, you keep all the great parts of the Flash IDE, while getting rid of problems it brings to the table.
My Personal Experience
I’ve done games both ways. Hover Taxi was with the Flash IDE, while The Game Conference, Collide Reactor and an unannounced one use Flash and Flex. Flash and Flex is the only way that I’ll continue to do game development.
The Downsides
There are some downsides to this approach. The good news is that they are pretty mild and easily overcome.
You need to roll your own Preloader
Yes, you’ll need to code a new preloader. Urban Squall has the best article I’ve found to do this. They’ve been kind enough to provide you with source code and a walk through on how to integrate it. (You will need to play with a compiler setting)
You can’t use the timeline anymore
Most people use the main timeline to keep track of the different states in their games – the Main Menu State, HighScores Sate, Game State, etc. You won’t be able to do that anymore. Instead, you’ll need to whip up a state machine to manage these. They’re easy to make and you’ll have more control over what happens when you switch between different states. (8-bit rocket has a good tutorial, so does Cheezeworld) This will cost you some time now, but you’ll have a state machine ready to go for the future.
Conclusion
With Flash and Flex, you’re less reliant on fla files and have better compile times? The upfront cost of switching is small and I recommend it. Just try it out. I don’t think you’ll be disappointed.
I’ve been using FlashDevelop and Flex lately, I’m liking the combination a lot. I do love the flash IDE, and I think it’s definitely the strongest thing flash has going on. I definitely see your points though, and very much agree with them.
We used FlashDevelop for Stupid Robot. It was a lifesaver to have an IDE. Didn’t use Flex though but from the sound of things it also makes your life easier.
I love you man.
I’ll switch over to Flex + FlashDevelop in my next project. I’ve been wanting to be able to separate asset libraries for a long time. The Flash IDE really sucks for programming, except for animation and graphics.
Great article!
I think there is some confusion about Flex. You don’t have to be using Flash Builder (formally called Flex Builder) to be using Flex. FlashDevelop uses Flex for compiling AS3.
This past weekend I had to cobble something simple together in the Flash IDE. Compile times weren’t bad, but as soon as I added one 5 second video asset my compiles tanked. Hopefully re-compiling large assets in a short amount of time will be fixed in CS5.
Yes, it sounds like you are making the common mistake of confusing Flex, the Flash-based RIA framework, and Flex Builder, the Eclipse-based coding tool (now correctly named Flash Builder). Flex/Flash Builder is great for building games. Flex itself is generally not appropriate for game creation.
When I say Flex, I’m referring to the Flex SDK.
If I write a class named swcSquare extends Movieclip, it doesn’t work anymore, but if I write swcSquare_element extends swcSquare it works perfectly, can you please elaborate this a little more. Thanks.