Creation of a game with flixel and Flash Builder 4
You should already know flixel.
I blogged a bit about it some time ago in flixel for absolute beginners and flixel for absolute beginners – part 2.
Now it’s time to make something serious, but in this first step I am covering again the basics of creation of a flixel game using Flash Builder 4.
Do you think I mispelled “Flex” with “Flash”? You’re wrong. Flex 3′s new version is called Flash Builder 4 and you can see the new features as well as download a 60 days trial at the Flash Builder 4official page.
So let’ start! Basically this tutorial is a porting of this one, just using Flash Builder 4. But a lot of new features will be added in various steps.
So let’s start creating a new actionscript project…

… name it HelloWorld…

… then select its properties…

… and under Actionscript Build Path select Source path then click Add Folder…

… browse and select the directory with the flixel package you downloaded…

… you should see it in the window now…

… then create a new Actionscript class…

… call it PlayState and make it son of FlxState class…

Now you’re done, and you should have to .as files: HelloWorld.as and PlayState.as
Your package explorer should look something like this:

This is what you’ll write in HelloWorld.as
1 2 3 4 5 6 7 8 9 10 11 12 | package { import org.flixel.*; //Allows you to refer to flixel objects in your code [SWF(width="520", height="240", backgroundColor="#000000")] //Set the size and color of the Flash file public class HelloWorld extends FlxGame { public function HelloWorld() { super(260,120,PlayState,2); //Create a new FlxGame object at 320x240 with 2x pixels, then load PlayState } } } |
And this is the content of PlayState.as
1 2 3 4 5 6 7 8 9 10 11 | package { import org.flixel.*; public class PlayState extends FlxState { override public function create():void { add(new FlxText(0,0,100,"Hello, World!")); //adds a 100px wide text field at position 0,0 (upper left) } } } |
No need to comment anything because I’ll do it in next tutorial, when I’ll create something more exciting and explain it step by step.
This is the (amazing) result…
… stay tuned
They can be easily customized to meet the unique requirements of your project.















(7 votes, average: 4.29 out of 5)









This post has 7 comments
HiddenSpartan
I’ve heard that there were problems with Flixel and Flex 4, I don’t know that they’ve been resolved yet.
Another interesting topic that I would recommend picking up: the free haXe compiler.
Tetris
I agree with HiddenSpartan. Rather then starting to learn Flex 4 and/or Flizel, I would definitly be more interested in reading and learning about haXe. I’ve heard only good things about it, so this would be something I’d love to read here :)
Emanuele Feronato - italian geek and PROgrammer
[...] Creation of a game with flixel and Flash Builder 4 [...]
amaca
I’ve set up my flash builder like you said, but i receive this error:
1120: Access of undefined property PlayState. HelloWorld.as /HelloWorld/src
i use flash builder 4 with SDK 4
amaca
excuse me, i have not called PlayState but Playstate the second .as
resolved;)
Sean James McKenzie
This is exactly what I was looking for. Thanks very much! I got myself all setup and am now whirring along with Flixel. I can’t decide if I like FDT or Flash Builder more. FDT has real-time error checking, which is nice, but Flash Builder seems faster… maybe? Either way, thanks for the post… very helpful.
Riccardo
hello all! someone needs a designer of monsters, levels, or something else???
I’m not too good at programming but I make my first game in flash the last year
check out: http://www.kongregate.com/games/saba7/saba7wars