Flash for Free
Page 5 of 5
<1 | 2 | 3 | 4 | 5>
Single-page view
Flash for Free

Uh-oh. You divided by zero, didn
Uh-oh. You divided by zero, didn't you?

Uh oh. Looks like the program threw some errors.

Fortunately, these ones are easy to fix. Go to the "import" lines in your code again. Remember that it was mentioned how these had this sort-of ability to extend the command set of your program? Well, we need to extend it now to recognise these text objects. So write this line with the other imports:

	import flash.text.TextField;

There we go! Try building the project again. It should go without a hitch. If there ARE problems, make sure that you're using the code template given to you by FlashDevelop, and that the only thing you're doing is inserting the lines circled in red. Also check that you've kept your "package" line at the top (not indicated in the screenshot below, so be warned).

We keep telling Nandrew not to draw red lines on his screen. He never listens. He
We keep telling Nandrew not to draw red lines on his screen. He never listens. He's not even any good at it.

Once the build is complete, run your project.

Hey, at least it
Hey, at least it's not 'Hello WORLD'.

Brilliant, you've made your first Flash application, and you did it without loads of money!

As a final parting shot: tweaking some of the output properties is really easy to do with FlashDevelop, and you may want to remember these for future reference. Click on the rightmost icon at the top of the Project window to get access to project properties. This will offer various output options (and many other adjustments) which developers should probably have a look at.

Project properties

Now, use this beginner's guide as a springboard, look up coding tutorials on the Internet (make sure that they deal with ActionScript 3, and not the Adobe Flash creator application or something else) and learn how to create your own Flash games like a pro. It's a fun and rewarding language that, as you may soon discover, is powerful enough to do a great many things and reach a whole lot of people. Happy scripting!



Words from the readers
I once was blind but now I see. Thank you my programming savior
Posted by joe at 23:32:45 on 09 September 2010
I honestly could kiss you for this. Your tutorial took me from *FLAILY-FLAILY-OMG-WHY-NO-WORKY?* to "Oh, hey! It's doing it!" (closely followed by an embarrassing pig-squeal of victory.)
Posted by edixoo at 05:10:24 on 07 September 2010
Thanks a lot man! Your peek into the world of non-WYSIWYG Flash development was very informative. :)
Also, auto-completion for the win!
Posted by Herman at 17:48:04 on 03 August 2010
thanks a lot for this wounderful tutorial
Posted by Kadri at 19:19:06 on 01 July 2010
Thank you so much for this article!! I would have gone crazy trying to figure out by myself how to get started. You are an angel! Thanks again!
Posted by Rafael at 22:43:47 on 29 June 2010
This is awesome .. Thanks ..
Posted by Nat at 03:29:41 on 29 April 2010
Hello.

Thanks for the tutorial and all, but I've downloaded the SDK and I point the FlashDevelop language settings to that folder, but it never <i>retains</i> it (after restarting). This is actually the problem that led me to your tutorial in the first place (FD's documentation site is rather terse, so I thought maybe I was missing something -- well, actually, I'm obviously missing something; I've just no idea what it may be). It <i>is</i> the <i>folder where the SDK resides</i> that I'm supposed to point it to, correct? It currently resides in a folder entitled "flash projects" on my desktop (WinXP) -- that is, the folder entitled flashsdk_whateverversionitis_orwhatever, with all its requisite extracted flashy SDKness.

Thanks for any helpful enlightenments you can provide.
Posted by Jordan at 17:06:22 on 24 April 2010
I've already done following your procedure. But I've got build fail.

thanks,
Posted by James at 09:19:24 on 31 March 2010
Awesome Tut! I'm a completely wet-behind-the-ears FlashDevelop (let alone AS3) newbie and THIS is totally the right start. It's also a lot easier to follow than the FlashDevelop installation notes & guidelines.

Thank you!
David M.
Posted by David M. at 08:55:50 on 28 March 2010
Hey this is really great! Easy to follow and does exactly what it says on the tin! Hopefully you'll do more of these, since most tutorials seem to be geared towards people developing in Flash CS3/4
Posted by falconi at 06:38:37 on 27 December 2009
I read through the whole thing but there was no As3 project at all so clicked default. there is no init() though so I was unable to get the project to run
Posted by mark at 07:06:13 on 18 December 2009
Thank you so very much for your help. I just needed a simple startup for learning actionscript with flashdevelop and so many sites had, well I had issues with so many sites. Thank you for your help again! I will email a company in a couple of days and say I just learned actionscript! Well I just needed to get it running. It seems like many other languages and so this gets me going! Sorry, blabbing.

Posted by seanmarillion at 02:21:56 on 08 November 2009
Ooh, missed that comment! Thanks, it's a good idea. I've made one or two minor changes in the article to remove ambiguity in these cases.
Posted by Nandrew at 15:16:12 on 24 September 2009
This tutorial is amazing! Furthermore: you should include the doubts presented in this comments thread in the tutorial itself, because i had the same problems as the other two guys.
Posted by Nek at 17:58:24 on 13 September 2009
Hey Jim!

The screenshot you're referring to chops off the top line: you need the word "package" on its own line, as well as an extra opening and closing brace to surround everything. If you're still having problems after that, I suggest you just use the base code template that FlashDevelop *should* offer you (that's what this article assumes as given), and simply insert the lines circled in red.

Hope that fixes everything -- let me know if you're still struggling, I'll check these comments for updates.
Posted by Nandrew at 22:12:59 on 20 August 2009
Thanks for this article - I found it really useful.

I ran this code - which seems to be the same as on your screenshot:

import flash.display.Sprite;
import flash.events.Event;
import flash.text.TextField;

public class Main extends Sprite
{

public function Main():void
{
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}

private function init (e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);

var myText: TextField = new TextField();
myText.text = "Hello Flash";
stage.addChild(myText);
}
}

But when I built the project, I got this error:

C:\DATA\My Documents\_jim\flash\FlashDevelop\src\Main.as(5): col: 1 Error: The public attribute can only be used inside a package.

I wondered if you might be able to advise please?

Thanks!
Posted by Jim at 09:49:30 on 19 August 2009
This may or may not have a simple solution.

I *think* you may have accidentally produced your code inside a source file other than "Main.as". When FlashDevelop starts a new project, it typically opens up a code window called "Untitled1". If you don't double-click on Main.as from the right-hand panel and work in that instead, you'll be coding in a file that never gets called by the program!

I strongly suspect that this is the problem: your code itself is fine, since I copy-pasted it into my dev environment and it displayed the text properly. If there's still a problem, double-check the IDE settings outlined in this article. The Flash version given in the example is by now a bit out of date, but the advice should still apply.
Posted by Nandrew at 02:15:47 on 13 July 2009
This is a very helpful article but when I try to run it it shows up blank any advice? Here is my code:
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.text.TextField;

/**
* ...
* @author ****** ******
*/
public class Main extends Sprite
{

public function Main():void
{
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}

private function init(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
// entry point
var myText: TextField = new TextField();
myText.text = "Hello lash!";
stage.addChild(myText);
}

}

}
Posted by Ace Fire6 at 14:50:22 on 11 July 2009
Thanks! If you're interested in reading further into Flash, don't pass up the opportunity to head over to http://www.gamepoetry.com/blog/ -- it's a very useful blog with some very useful articles, and served as a major inspiration for this piece.
Posted by Nandrew at 18:22:49 on 06 May 2009
i have looked all over the web and this is the best of them all for a beginner
Posted by xraser at 13:35:19 on 06 May 2009
Have your say: