Sep
18
2010

How to become a better Flash developer

Developing in Flash can be a fun and rewarding experience. From widgets to games to enterprise level applications there is a vast array of challenges a Flash developer will encounter on a day to day basis. Here are 10 Flash tips for improving your Actionscript 3.0 knowledge to make you a better, more productive Flash developer.

For the best tutorials, Follow netglos @twitter and netglos.com

1. Don’t write code on the timeline

If you want to become serious about programming in Actionscript 3.0 then at some point you need to do away with coding on the timeline. The Flash IDE is a tool built for designers… not developers. While the Flash IDE does have a code editor built in, it is far from that of a dedicated coding environment like Adobe’s own Flash Builder or FDT.

There are cases when writing code on the timeline is necessary (play, stop, gotoAndPlay etc.), but for the most part you should never be writing more than a few lines of code.

2. Embrace OOP

Those moving from Actionscript 2.0 to Actionscript 3.0 will quickly discover there is a very big difference between the language versions. AS3 is an object oriented programming language, there is no escaping that. AS2 has foundations of OOP but it is not as core to the language as AS3.

It is quite common to code Actionscript 2.0 in one long monolithic chuck of code. This will work and you can certainly code Actionscript 3.0 this way too but it is not best practice.

Learn to take advantage of the benefits of object oriented programming in AS3 and I guarantee you will wonder how you ever survived without it.

3. Comment your code

Writing beautiful code is one thing, but understanding what you’ve written in 6 months time is something else. Commenting code is something which won’t make or break your application but it can be an invaluable and useful thing to have, especially when first starting out learning Actionscript 3.0.

How much you comment is often dependent on who is looking at the code or more importantly, who might need to look at the code in the future. Whether you are a sole developer working on a game or an enterprise level guru, good code commenting is a nice habit to get into.

4. Participate in the community

There are many great places online to interact with other Flash developers and designers. Joining in on discussions on forums such as kirupa, actionscript.org or gotoandlearn is a great way to be social and learn from others.

There is also a very active community on Twitter. Check out this list to find some prominent and inspiring Flash enthusiasts (also why not follow ahrooga while you’re at it!).

5. Plan ahead

An analogy I like to use when thinking about OOP is of an artist creating a sculpture. Imagine you had large block of clay you wanted to turn into a bust of someones head. You would be insane to completely sculpt a nose before shaping the block into something resembling a head. How can you sculpt a nose before knowing where the rest of the face is?

Programming is like sculpture in that the logical thing to do is plan out where things need to be before getting too engrossed in the finer details. Taking a moment to step back and look at the big will make you better at avoiding potential pitfalls early on.

6. Diagram

Don’t overlook the idea of using a pencil and paper once in a while. Drawing diagrams can help visualize how your program links together by demonstrating the interconnecting parts. It will save you time in the long run and stop you ending up with spaghetti code.

Did you know there is a standardized way of diagramming OOP systems? Check out the Unified Modeling Language (UML) if you are feeling adventurous.

7. Learn the intricacies of the Flash Player

Learning how the Flash Player works is important to understand how memory is managed, how garbage collection works and what the differences are between player versions. Colin Moock’s book Essential Actionscript 3.0 is an excellent overview of the language as well as some of the more obscure workings of the player.

8. Analyse other people’s code

As there is a wealth of existing code snippets and libraries available for Actionscript 3.0 it becomes very easy to add some sophisticated functionality to your project without truly knowing how it works. Take the time to look at code written by others to better understand why something works the way it does. This is a great way of discovering new tips that can help you with your own day to day coding.

9. Learn design patterns

Like many modern programming languages, Actionscript 3.0 is an object oriented language. To better embrace the power of OOP, design patterns are a must-learn. Design patterns provide ways to structure your code to solve common reoccurring problems. There are many different forms of design patterns, each providing solutions to very specific needs. They help you to better structure the parts of your application as well as making you become accustomed to the core principles of OOP such as inheritance, encapsulation, abstraction and polymorphism.

You may be surprised to learn that you have been using some of the more common design patterns in your code without even knowing it had a name. The event framework in Actionscript 3.0 is actually using the Observer design pattern when you add a listener to an object using addEventListener.

Head First Design Patterns and ActionScript 3.0 Design Patterns are both excellent books on the subject.

10. Learn another language

As great as Flash and Actionscript 3.0 are, learning another language can be surprisingly eye opening as it forces you to look at problems from the perspective of a different syntax. Tips and tricks discovered while programming in one language can often be transferred to another.

It’s a little too easy to get comfortable working with DisplayObjects and event listeners to the point of becoming ignorant to the world outside of the Flash player. Learning a complimentary language which can be used with Flash is a great addition to any developer’s skill set and will give you a fresh perspective on programming in general. I highly suggest looking into a server side language such as PHP or Python.

Got a tip?

Got some advice on becoming a better Flash developer? Leave a comment below!


Popular Posts