Beginning Flash and ActionScript Game Programming Part 1: Introduction to Flash Game Programming and Useful Terms

 

This section is to introduce you to Flash, Actionscript 3.0 (as3), and some associated terms.

Introduction

Game programming can be fun and enjoyable, but it is hardly ever easy.
You can learn the basics from other people, but a lot of stuff you’ll have to struggle through and figure out yourself.
The most fun part for me is seeing your creations come to life, especially after putting a lot of time, and effort into making things work the way you want to.

Let me know if you create any cool games based off my tutorials, or if you don’t understand some of the information!

Why Create Games Using Flash?

Once you learn the basic programming techniques in any programming language, you can program games in any other language much easier.

But why program games using flash?

Some of the things that makes flash a good candidate for game programming are:

  • Easy to have other people play your games, which leads to quicker and a lot more feedback, which helps you learn and refine your games. Flash runs in the browser, and your game will get a lot more exposure if all someone has to do is click on it, versus needing to download and install it, risking potential viruses.
  • Many tools already built in. It’s very easy to display graphics quickly using Actionscript, as well as play sounds, load XML, and even communicate with servers to store data on the web.
  • Easier to get started than C++. In flash, you can quickly focus on the core game-play, whereas other programming languages like C++ using DirectX or OpenGL, you have to handle window initialization, troubleshooting library importing issues, and handling memory management. In Flash, most is handled for you, which allows you to focus on creating your game.

Some drawbacks to programming in Flash:

  • Flash is much slower than C++ or Java. For very intensive games or applications, flash has too much overhead and significantly slower than a similar program created using C++ or Java.
  • The Flash IDE and Flex Builder IDE are limited in code completion, and more difficult than other IDE’s to program in (but this can be fixed by using FlashDevelop).
  • Limited choices. TO make development easier, a lot of choices/ freedom is removed in flash. You can’t decide on a different renderer, there are a limited number of IDE’s, you can’t clean up memory that is no longer being used, and apple has decided not to allow their devices to view flash content.

All in all, with using FlashDevelop, I think Actionscript is a great language for beginners looking how to program games.
It’s pretty simple to use, pretty forgiving, but also has the power of a full language, to create objects, classes, class inheritance, and pretty much everything you would have available using C++.

Some Terms to Know

When talking about game programming in flash, there are some terms you need to know.

The flash player: This is what is installed on any computer able to see flash videos, or games online. The user has to install this browser plugin, which will allow them to view flash content.

Most computers already have this installed, and an easy way to tell if a moving video/ game is being rendered using flash is to right click on it and check for ‘Adobe Flash Player’.
The flash player runs on Windows, Linux, Android 2.2 and above (Froyo), and even Mac OsX. Apple has chosen not to let their users use it on iPods, iPhones, and iPads.

Actionscript: Actionscript is the programming language used to program flash content. ActionScript 3.0 (also known as as3) is the current version, and is a full object oriented language, unlike its previous versions.

Object Oriented Language: This is a language that allows you to program by creating objects.
For instance, if you want to create a table in your game, you create a CLASS called ‘Table’.
From this class, which is basically a blueprint of what the object can be, you can create Table objects.

For example, you can create a table class that can contain the number of legs, and the height of the table, and create two different tables by filling in how many legs each will have, and how tall.
This will be explained further in future tutorials.

Flash Develop : This is the preferred IDE (Integrated Development Environment) for programming in ActionScript, and is offered completely free and open source!

An IDE allows you to input text/code, check to make sure the code syntax is correct (looks for simple errors), and compiles your code into a program that can be run.
In addition, FlashDevelop has intelligent code hinting for your code and built in functions, which makes it easier to learn, and quickly look up function parameters.
It also auto imports any libraries you need as you create objects that depend on them, as well as being fast and efficient to code and compile in.

The Flash IDE, aka Flash CS3, Flash CS4, Flash CS5, ect: This is the IDE created by Adobe, which is primarily used as an animation tool.

It uses timelines to easily be able to put together animations, as well as features tools for drawing similar to Adobe illustrator. Flash cartoons are created using this, and you can even create a SouthPark like cartoon using it!

It does support using ActionScript, but it is best used for controlling drawings on stage, rather than as a full programming environment. Flash CS5 has limited code hinting, but is a chore to use compared to FlashDevelop.
The best things to use this are for creating vector images, animations, or for simpler ActionScript commands, such as making quick animations on a flash based website. You can use it for programming ActionScript, but it’s much more of a chore than using FlashDevelop, and can be a pain to use at times, since it’s built primarily for animating.

Flex and MXML: Flex is an SDK released by Adobe, which allows FlashDevelop to compile flash programs, as well as introducing a language used for programming applications called ‘mxml’.
MXML is basically very similar to HTML – you use tags to create objects, then use ActionScript instead of Javascript to make it interactive.

It is pretty easy to get started in it, and very useful for developing desktop applications using Adobe Air.
Adobe Air provides additional functions, to allow you to load and save to disk, drag and drop files/ images directly into the application, and giving you all the told you need to make a complete desktop application fairly quickly.
Flex and MXML can also be used for creating web applications, but it’s very useful for creating desktop applications.

Flash Builder aka Flex Builder: Flash Builder (which was known as Flex Builder) is Adobe’s IDE for developing Flex Applications. It is built upon the open source ‘Eclipse’ Platform.
FlashDevelop can also build Flex applications, but Flash Builder has tools to make it easier. It includes a visual layout view, so that you can drag components, such as textfields, buttons, drop down menus, ect, directly onto your application. It is also pretty good at code hinting for Flex tags, but still lacks for code hinting for Actionscript.

Conclusion

So now you should have some idea about the terminology surrounding Flash and ActionScript game development.

In the next section, I’ll show you how to download and setup FlashDevelop, and compiling your first program.

Where to go from here?

First check out the next tutorial. After that, there are several books on flash game programming using ActionScript , as well as blogs and websites.

I’ll post the ones that I have found helpful, or refer to often in the ‘Resources’ section on the toolbar at the top of the page.

Other Articles in this Series

Bookmark the permalink.

6 Comments

  1. Heard through @bdsexton that Apple has relented and now allows publishing of games/apps through flash cs5!

    also a link to more info: http://www.infoworld.com/d/developer-world/escape-the-ios-sdk-building-iphone-and-android-apps-flash-158

  2. Just finished memorizing part 1… It was easy to understand and i appreciated the pros and cons since I was debating over other programs before i stumbled here. Thanks!

    Moving on to the rest…

    • Thanks for checking it out! Let me know if you have any issues, or any ideas for future tutorials-

      • Actually, I’ve been stuck on part 2. It’s a little embarrassing but because I’m currently using a mac now, I don’t have access to Flash Develop. But I do have Flash & Flash Builder, also a trial for FDT so I tried applying the tutorial on those. But finding something so little as entering an Entry Point was quite a task.. So much so that I spent all night googling it with no luck.

        • Ah- yeah, thats one issue with FlashDevelop, it was programmed in C# and works only in windows :(
          If you have a legit copy of windows somewhere, even XP on a cd, you can install it on a virtual machine on your mac, using ‘virtualbox’, or several similar programs.

          Alternatively, with FlashBuilder, don’t worry too much about tutorial 2 – thats specifically for FlashDevelop.

          Just go to File->New Actionscript project, call it ‘Main’, and under public function Main() add ‘trace(“This is my First Game!”);’. And hit ‘F11’ to compile it.

          The event stuff, and all that code is autogenerated for FlashDevelop, but FlashBuilder generates its own bare-bones Actionscript file. For some reason it doesn’t need to wait until the ‘stage’ object is available- it has it already.

          I should probably look into making the tutorials concurrent with FlashBuilder and Flash IDE, at least for the beginner set-

          Let me know if you need any more help!

  3. I went out to get Flashdevelop. Wow, it was easy. While the guide has everything I need in my dream game (especially Part6 Functions), I have a hard time visualizing how the result would look like if I do it correctly… Even though I can just copy and paste.

Leave a Reply

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