Subscribe to Depricated's Blog        RSS Feed
****- 1 Votes

Learning Flash as a (Somewhat) Experienced Programmer

Icon 3 Comments
So as I decided to move in to using Flash, I had a series of questions. These questions I asked initially in the Flash & AS3 Forum Tutorial Request thread, with a series of questions which I decided to answer as I learned.

I am by no means an expert at any of this, mind you, but this is as good a springboard as I've found.

So, to get started, all you really need is an IDE - while an editor like Notepad++ will work for writing ActionScript, it lacks the debugging tools and compiler, as well as a deal of other features. I use FlashDevelop. For that you'll also need to grab the Adobe Flex 3 SDK and the Debug Player. The setup instructions for FlashDevelop will explain what exactly to download and where to put it. This is all you need. No server, nothing like that.

One of my first questions was this: "Flash is a proprietary language, and as such has a ridiculously expensive retail IDE. I've installed a 3rd Party IDE (FlashDevelop) in lieu of forking out bags of cash. Am I going to be at a disadvantage in learning the language and working with it?"

This looks like a no. The first thing I did was request a free copy of Flex Builder from Adobe - which it turns out they're happy to give to programmers who simply want to learn the language, with the promise that it won't be used for production. It's still technically a trial version, but it's an extended trial. My hat is off to Adobe for that, it totally turned my opinion

around about the price of their software.

Anyway, it is comparable to FlashDevelop. However, it has some notable benefits such as the Design board. It appears, though, that any graphical application will work for this purpose, it's simply a matter of associating images with the Action Script files. In that regard, learning through Flash Builder may be as bad for learning Flash as learning through Netbeans is for learning Java. This is to say, a crutch rather than a guide. On the other hand, FlashDevelop seems to have some decent debugging and code generation as well. I just noticed that if I forget an import it will automatically at the import to the list, for instance, when I extend to use it. Both appear to be helpful.

Since my primary concern is the difference without the drawing board, I used a kit called FlashPunk and followed through the tutorial on its use. This demonstrates that the drawing board feature isn't a necessity, which is important. Also we can look through the SpriteMap class to see exactly how it's rendering. Of course, we want to avoid learning a package rather than the language, so it's important to note that this class inherits from flash.display.BitmapData and look at that.

With this, we can do all of our drawing in, say, gimp, and just call in the images by the objects that will use them.

This answers the questions of where to learn drawing in AS3. The answer is anywhere that you might learn to draw on a computer at all. Image files are usable, and there are a number of actual drawing classes that work identically to Java. Which brings me around to the parallel with java.

Now let me explain quickly that ActionScript is the language of the Flash platform. You don't write in Flash, you write in ActionScript. So if you've noticed me refer to ActionScript, ActionScript 3, or AS3, it's because that's the language, Flash is the platform. It's the same difference as HTML and a Browser - theres the language and the platform for it.

Anyway, ActionScript 3 appears to be Java, almost. There are a few key differences, and an array of different objects and classes of course, but the important part - the syntax - seems the same. The first important variance is Variable Declarations. Like every other language I've come across so far, AS3 has it's own fun method of declaring variables. This is more akin to C#, but barely.

In the declaration you first declare the visibility of the function, such as private. Then you declare whether it's static. Next you declare the variable name itself preceeded by "var" or "const" depending. So far so good, right? Now we get into the fun part. No spaces here, add a colon and declare the datatype. Then you can assign(or not if you choose).

So, a few declarations might look something like this
private var yes:Boolean = true;
public var i:int = 0;
protected static const bg:BACKGROUND = background1;

Make sense? Easy enough once you break it down. The next major difference is datatype declarations on functions. A function that might look like this in Java:

public void draw(Image e)

would instead be written as

public function draw(e:Image):void

So in short: datatype declarations appear to always come after the data name declarations. So functions, constants, variables, etc all end with a :datatype. Now, the thing that really disappointed me is Threading. ActionScript is single-threaded, so that's a huge limiter. However, threading can be faked with the Timer class, by adding events to the Timer. It's not perfect, since everything on the timer still runs sequentially, but it's better than nothing at all.

A notable annoyance is the addition of yet another level of indentation. Everything exists inside of a package, so your class will look something like this:
	import flash.display.BitmapData;
	 * @author depricated
	public class Main
		public function Main()

Package works similarly to Java, but everything sits inside of it, basically. In Java we get to just declare it before imports and leave it at that.

You might also note that the declaration of the constructor doesn't require a datatype declaration. Likewise, main isn't static like it is in Java.

These are relatively minor differences, though. Arrays are declared the same, loops are pretty much the same, and all your operators. It's an easy transition, though you do have to mind you don't slip on one of the small differences.

Also like Java, Flash doesn't support SQL. However, there's a simple workaround for this: Flash DOES use XML. As such, you can use PHP to dynamically manipulate an XML file with data from an SQL Server. Since PHP and XML are beyond the scope of this tutorial, I've provided the link below that explains in detail how to access SQL Data through a PHP-modified XML file.

In closing, I have no deep wisdom to share as an experienced Flash developer. I'm still a newbie myself. So what I will say is this: as you transition to a ActionScript 3, try not to focus on what you know of Java. Despite the similarities, it is a new and different language, and the easiest way to make mistakes is to momentarily forget what language you're writing in.

FlashDevelop: http://www.flashdeve...title=Main_Page
Flash Documentation: http://livedocs.adob...criptLangRefV3/
PHP, MySQL, and Flash: http://library.creat...e/php_mysql.php

3 Comments On This Entry

Page 1 of 1


09 May 2010 - 07:16 AM
I too am a Java programmer learning AS3. I picked up ActionScript 3.0 Bible (seems good so far) and to be honest, I'm still reading through the Programming With Classes chapter (p. 55). Like you said, it bears many similarities to Java and makes me very comfortable reading through. I could probably skip the first couple chapters because it seems to only be repeating what Java taught be, but I figured there is no harm in reinforcing concepts and being weary of subtle differences.

I'm disappointed that AS3 has no way of communicating with SQL databases, but I suppose XML will suffice. To be honest, I just can't wait to write some fun graphical applications!

Also, as an off topic question, why is it bad to learn Java through NetBeans? I'm only so experienced with Java (just finished reading Head First Java and Sam's Java in 24 hours), but I haven't come across any difficulties or squeamish non-professionalism from NetBeans. Perhaps you're referring to the GUI building side of NetBeans?


10 May 2010 - 04:23 AM

evinrows, on 09 May 2010 - 06:16 AM, said:

Also, as an off topic question, why is it bad to learn Java through NetBeans? I'm only so experienced with Java (just finished reading Head First Java and Sam's Java in 24 hours), but I haven't come across any difficulties or squeamish non-professionalism from NetBeans. Perhaps you're referring to the GUI building side of NetBeans?

Actually it's the code completion. It's a great feature, it's useful, but I've run in to people who use it as a crutch. I don't expect everyone to memorize every class and package, but learning without Netbeans before moving to it helps to learn the code rather than the pattern - at least in my experience. By all means, if you don't make the mistake of letting code completion prevent you from learning, it can be a boon. FlashDevelop does the same thing. We just have to take care.


10 May 2010 - 11:41 AM
Ah, I see, thanks. Yeah, I don't normally choose from the drop down box what I'm looking for. Before using NetBeans (which at first annoyed me) I hated all IDEs and just wanted to type everything out in notepad++. :)
Page 1 of 1

Trackbacks for this entry [ Trackback URL ]

There are no Trackbacks for this entry

June 2018

24 25 2627282930

Recent Entries

Recent Comments

Search My Blog

0 user(s) viewing

0 Guests
0 member(s)
0 anonymous member(s)