Things I wish they’d told me about Flash

by Martin on 4/05/2007

Just to get started I'll repost this entry which got a bit of positive feedback when I first wrote it.

Flash has really matured the last couple of years, and noone (well… few) are still arguing that Flash is unsuitable for anything but irritating intro-animations and mystery meat navigation. Google, MySpace and YouTube are embracing Flash for their video players, and for product minisites that needs that extra touch of zipdeedoo it's arguably the best medium.

If you're just starting out in Flash there's a few things you're gonna have to learn. Unless you have some secret tricks up your sleeve (lists like this to mention one) you're gonna have to learn them the hard way, and nobody likes the hard way. The hard way is a long and desolate path with a lot of wailing and gnashing of teeth and while you wail and gnash the people who are not walking the hard way are laughing and throwing little rocks at you.
With that in mind; here's some little tips and tricks for making your life developing rich internet applications easier.

  • 1. There is no way around it. You will have to learn Actionscript.
    I came from a design background, so what initially drew me to Flash was the possibility of creating websites with a truly cross browser consistant WYSIWYG. The special effects were an added bonus. I realize that very few would have such a narrow goal in mind, but the Flash IDE looks deceptively like Photoshop and Illustrator, and as such tricks many people into believing that's all there is to it.
    I'm sorry. The true power of Flash lies in it's scripting language. You may not believe me, but in a few months when you see how limited the tools in the IDE are for creating rich internet applications you'll see what I mean.

  • 2. As much as possible keep your code in one place.
    No really! I know that to begin with it seems much simpler to litter your code on any movieclip, button and frame that seems most appropriate at the time, but this'll cause you a lot of grief later.
    Not only will it be virtually impossible for you to track down the code when you want to change something later on, but this practice also makes progressing in Actionscript a lot harder since decentralized code is really really bad when you start to do cool stuff like functions. (Which'll happen sooner than you think.)
  • 3. There is absolutely no need to use the button symbol.
    The button symbol may seem the most logical for click-functionality in your flash project, but it's also severly limited in what you can do with it. Compare it now with the MovieClip symbol. The backbone in your movie (at least until Actionscript 3 becomes your weapon of choice). The MovieClip has onClick-events, so you can easily use it as a button, but it can also do virtually anything else you'd ever like it to. Without the icky practice of putting the code directly on it. It's a wee bit more complicated than the Button symbol, but you'll be thankful for the extra effort soon enough.
  • 4. No scenes. Ever.
    The use of scenes harks back to yon days of old when Flash was severely more limited as a way of dissecting your movie into manageable chunks. If you need to split your movie up into pieces (as you surely will) use external .swf files that load into a main movie.
  • 5. Be lazy
    If you're anything like me (and why wouldn't you be) you'd rather be out in the sun with a cold brew than smacking your head against the monitor typing the same “someClip.onRelease” 50 times. This and other menial tasks can so easily be avoided with just a minimum of extra coding skills. In general the more generic you can make a snippet of code, the more often will it be applicable again and again. If you take the time to learn how to use functions, arrays and for-loops you'll have so much more time for frolicking in the summer weather and ogling the young [insert preferred gender here].
  • 6. …but not too lazy. (_root is evil)
    Well… In fact this is another way of being lazy by doing a little extra work up front. Avoid using _root as much as at all possible. And for the same reasons be vary of global variables. The reason? You've built a sweet MP3-player for your current project, and some months later you need the same functionality for another site. Now… You merrily drag and drop the MP3-playing clip into your new file and snicker while thinking about the work hours saved. Only the dang thing refuses to work, or worse; it completely hoarks up your site. Chances are you're dealing with a wayward _root reference.
  • 7. Name everything
    So you've come to appreciate symbols and you're dragging instances all over your stage rather than creating separate MovieClips for every willy-nilly button you wanna populate your movie with. You've learned that keeping stuff on different layers is smart for organizing your file. Now… What the hell is that mask layer masking again? And when you want to expand your functionality; What good is 24 unnamed instances of that generic MovieClip going to do you? Even if you don't plan to do anything special with a TextField or a MovieClip, name it and name it…
  • 8. …descriptively
    You've come a long way now since you started out. You've even learned to chunk your code into functions for easier usability. I'm so proud of you… But what exactly did greenClip(); do again? If you can even remember it through day 5 of your project I'm willing to bet top dollar you can't five months later when you could really use that exact functionality in a new project. The same goes for MovieClips. What good is a description like someClip going to do you? Very little…
  • 9. Don't just snatch that code. Learn it.
    The way you're going to learn Actionscript is by snatching code from different tutorial files and using it in your own projects. All good. In fact I'd say it's pretty much the only way to go about it. But do yourself the favor of actually figuring out how the code works, even if it seems like it's several leagues ahead of what you'll ever be capable of. By studying other peoples code, not only will you learn faster, but you'll also be able to fine-tune it to fit other purposes than what it was originally intended to. (Oh, and do be polite. Don't blatantly rip off others work.)
  • 10. Embed your fonts.
    Unless you plan to have only static text in your files, chances are you'll find yourself in some forum asking a question like “Why doesn't my dynamic textfield work when I…”. Before you go and make that post: Embed the fonts. Even if it's verdana. 7 times out 10 this'll solve your problem.
  • 11. Comment religiously.
    This is one of the first things every book on Actionscript (or indeed any language) seem to say. Nevertheless it took me way too long to implement this most holy of practices. It's like this: One month from now you won't have the faintest idea what the code you write today means. Trust me. Not. A. Clue. So comment it. Comment it verbosely as if you're explaining it to someone who never worked on this project, because chances are good that one will be you. Learn to love your //'s and your /**/'s.
  • So there you have it. My little tricks for avoiding a lot of pain while writing Flash applications. If you have anything to add to this list, shoot. I'd be glad of your tips.

No comments yet.

Write a comment: