MGAS3FD 6: Click it like it's hot

Hello there. This is the sixth part of the Making Games in ActionScript 3 using FlashDevelop

By now we’ve got almost all the basic building blocks to make a simple game. All that is missing is how to get some input. Last time we touched on it a little bit using the mouseX and mouseY properties.
Those are the most straightforward to get at, but other inputs aren’t very complicated either. Let’s start with the mouse button.

Continue reading

Posted in code, Making Games in Actionscript 3.0, Tutorials |
  1. Hi Everyone, I also wonder what happened to our AS3 “teacher”. I really enjoyed his/her teaching. I hope he/she will return one day and continue the teaching. I would like to learn how you handle sprite collisions, scoring, removing objects when hit by other objects, scrolling of backgrounds, taking/porting the game to IOS and Android etc, etc. A tip for those of you that follows the tutorial to the teeth but got no response when clicking the “enemy” object, remember to look in your toolbar at the top of your development tool for the dropdown saying “Release”. It should be next to the blue triangle. That dropdown value should be “Debug”. You will only see the “trace” messages displaying in your “Output” window when that setting is “Debug” just before you “Build” or “Test/Run” your project. When you sometimes download the project files and overwrites your project with his/her project files you will find that setting is set to “Release” and you need to set it back to “Debug”. Happy Flashing. Gert Myburgh South Africa

  2. 4 years and no more parts… Are you dead?


  4. AddEventListener dosnt seem to work in any class except main. it compiles and runs, but dosnt catch and clicks on its assiged object. help??

  5. These are really great tutorials, but it gets kind of hard near the end, but I eventually figured it out. If anyone comes by here and needs some help, here is my final code. package { import enemies.Enemy; import flash.display.Sprite; import; import; public class Main extends Sprite { public var enemy:Enemy; public var player:Player; public function Main():void { addEventListener(Event.ENTER_FRAME, handleEnterFrame); addEventListener(MouseEvent.CLICK, handleClick); player = new Player(); addChild(player) enemy = new Enemy(); addChild(enemy) enemy.x = 500; enemy.y = 400; for (var i:int = 0; i < 5; i++) { var tmpEnemy:Enemy = new Enemy(); tmpEnemy.x = Math.random() * 800; tmpEnemy.y = Math.random() * 600; addChild(tmpEnemy); } } private function handleEnterFrame(e:Event):void { player.x += 1; player.x = mouseX; player.y = mouseY; } private function handleClick(e:MouseEvent):void { trace("clicked in main"); var targetEnemy:Enemy = as Enemy; if (targetEnemy) { targetEnemy.y += 20; } } } } Hope this helps!!!

Another forty bytes the dust.

I really should let this whole 4k game thing go. But as I was sitting on the train today, idly hacking away at a completely different game I remembered a curious thing that I didn’t have time to investigate then. The mysterious bytes.

Continue reading

Posted in 4k, code |
  1. Wow that’s pretty interesting actually! Good find and good explanation!

    Johnthegaylizard, January 5, 2010 at 22:28
  2. That’s awesome. Good sleuthing!

  3. That’s hardcore ๐Ÿ˜€ Good to know!

  4. Middlingly interesting information ๐Ÿ™‚

  5. that’s… GREAT

MGAS3FD 5: Enter the frame

Welcome to the fifth part of Making Games in ActionScript 3 using FlashDevelop.

Wow, when Iย  got started on this whole tutorial thing I never expected it’d take four parts just to get to the enter-frame part. But here we are.

This post will be about making stuff move. But before that we’ll need a quick primer on Events. They is one of the mainstays of actionscript, especially version 3.

Continue reading

Posted in code, Making Games in Actionscript 3.0, Tutorials |
  1. I FINALY got it to work. Turns out I accidentally put a semi-colon after void.

  2. When I do everything up to the private function handleEnterFrame(e:Event):void; { trace(“enter the frame!”); } bit but when I test it it gives my the following error: ‘Function does not have a body. private function handleEnterFrame(e:Event):void; {‘

  3. Thanks for the help David, I was stuck on that, too ๐Ÿ™‚ Thanks for all these tutorials!

  4. Okay, I FINALLY got that friggin’ gnome to move! Turns out I had to put enemy.x+=1 into the handleEnterFrame function, and not in Main(). To the guy who made the tutorial: a revision making that fact clearer would be much appreciated.

  5. I’m good up until I enter “enemy.x += 1;” which completely fails to move the gnome. I _am_ changing the one in, right?

MGAS3FD 4: More embedding

This is the fourth part of Making Games in ActionScript 3 using FlashDevelop.

gardengnomeLast time we got our first enemy on the stage. Now we’ll take a quick look at embedding other formats into your classes. Grab the gnome here to the right and put him in your assets folder.

Continue reading

Posted in code, Making Games in Actionscript 3.0, Tutorials |
  1. It seems like most of the issues in these comments have yet to be addressed, still very confusing, and it’s been two years, though still super grateful for these tutorials!

  2. This is the fourth one, not the third.

  3. Why is still the Sprite class there, if the bitmap class is the one you need?, you need both? , If we arent working with vectors anynmore, why do we need Sprite?

  4. I’m picking up AS3 from learning C++, and I don’t really understand what’s going on with [Embed(source=’../../assets/gardengnome.png’)] private static const GfxGnome:Class; Is GfxGnome being declared a class? You say “the GfxGnome class” in your article, so I guess it is…but then the ‘class’ is functioning as a static const at the same time? Or is it that GfxGnome is declared a class from within the Enemy class and is made to hold only one thing? ): I know very little about AS3 so an explanation would help greatly

  5. Basically I just made sure the import was correct and that it extended bitmap instead of sprite, and it worked fine. I don’t know what that other business is. I even resized them and made them semi-transparent. Maybe you mean that you shouldn’t have flash resize them just because it’s too slow for real time? Anyways I’m skipping all that extra class mumbo jumbo, this works and i’m fine

a winner is me.

4k_firstCheck out the competition results over at gamepoetry. There was tons of impressive entries, second place winner Dungeon Romp is really neat, it manages to tap into the latent rpg grinder inside of me. But I can’t help but feel the bytes spent on the 3D-walls might have been better spent on maybe items or something, since all I use to get around is the map. It’s nevertheless a great game!

Other entries I enjoyed are:

  • 4kpillars. A very cool looking game, the flying on a sphere mechanic works great.
  • Falling with style a technically very impressive entry, I’ve always loved pilotwings.
  • Ghost4koin really makes me wonder how they managed to fit that in 4k
  • Pie is maybe the most complete of the entries, also great!
Posted in News |
  1. Just thinking about this some more… One thing I think is really cool about it, in addition to the satisfying way you carve out blocks from the big shapes, is the sense of contrasting scale. The big blocks really move slowly but with great momentum, and they feel like giant ice bergs or space ships or something and you feel very small. I think this would be a lot of fun with multiplayer, in some sort of collaborative game. It would also be fun as a competitive free-for-all, or a team-based competition. I would really enjoy such a game if you’d be willing to make it. (and if you don’t, do you mind if I do?)

  2. Wow, I really liked your a-steroids4k game. It has a really interesting mechanic! Are you thinking of elaborating it into a bigger game? I would definitely like to play it if you do.

  3. Congrats on your win! Your game was a lot of fun and technically very interesting. I’m going to have to dig through the source and see what I can learn. If you have a pre-optimize, friendly-to-read version, I’d certainly be interested. ๐Ÿ™‚ I’m the developer of Dungeon Romp 4k. I agree that game lacks a certain lasting fun factor, and I was mostly going for technical merit to feel out the limits of 4k. The 3D walls actually weren’t terribly expensive, all things considered. I think they were worth the cost. From a gameplay standpoint, I should shrink the minimap way down so it becomes a secondary navigational tool rather than the primary one. Unfortunately, I couldn’t fit enough other interesting things in the maze to justify it, so I blew the map up to make the game easy to parse. The random maze generator was actually proportionally the most expensive. If I were going for pure fun factor, I should’ve dumped the mazes, hardcoded 10 floors or so, added in a basic item system and an endgame condition besides dying. ๐Ÿ™‚ I’m working on a full version of Dungeon Romp that addresses these issues outside of the 4k limit. ๐Ÿ™‚

  4. awesomeness in a jar! congratulations!

  5. Woo, congratulations! I still think 4k-steroids is the best of the competition. ๐Ÿ™‚ You’re an optimizing maniac!

MGAS3FD 3: Getting on with it

This is the third part of Making Games in ActionScript 3 using FlashDevelop.

Okay kids. Lots of boring setup stuff in the first two parts. It’s time to get some graphics in the mix!

As a side note, since we’re using what’s called the mxmlc compiler everything I do in this tutorial can be done using whatever IDE you please as long as it uses that compiler, if you’re really into this whole command line thing you don’t even need the IDE.

Continue reading

Posted in code, Making Games in Actionscript 3.0, Tutorials |
  1. Thanks for the tutorial, it’s very usefull and I didn’t found elsewhere how to use FlashDevelop.


  3. No CSS?


  5. Oh sorry for the last comment, I figured it out. How to save the leek picture :)?


Get Adobe Flash player

So, here it is, the full 4089 bytes of it, a-steroids4k for the gamepoetry 4k flash game compo.

I’ve been wanting to remake an old retro game with new mechanics for some time now but I’ve never had an idea I though worthwhile, there’s way too many half assed remakes out there and it’s hard to beat really innovative ones like 1D tetris or some crazy space invaders version. This is my take on asteroids. I played the original on the proper hardware a few weeks ago and was amazed by two things; The XY-vector screen is *really* bright and it’s hard. Very hard.

So I wanted to juxtapose the underpowered feel and make the player way more powerful, this is a bit tricky without making the game far too easy. The easyness wouldn’t be a problem in itself, but to feel really powerful you need to have a baseline of “weakness” to contrast against.

The basic mechanics came to me on a train ride, luckily I had my trusty laptop near and could churn out some quick proof of concept code then and there. It was only later the 4k competition was announced. I’ve done a game for a 5k compo in the past and enjoyed it immensely, the result of this was lost in a hdd crash and is unfortunately not available anymore. When I started slimming down the game was at about 29k. I ripped out all the sound and got down to 18k (yes, the sounds were tiny). I’d love to post screenshots, but, honestly the game has looked more or less the same ever since it’s conception. Ever since then it’s been a lot of aggressive cutting and small amounts of putting back in.

The full source code is under theย  MIT License, but a word of warning is in place, this is essentially obfuscated code seeing that I needed to shave of some extra bytes to get the text in there.ย  I also put it up on wonderfl for your fiddling pleasure. I bet there’s a good 20% of savings in there that I just missed, I’ll be thrilled by any modifications to it!

Posted in 4k, code, Games |
  1. This is awsome because it’s a clear contrast to Devil May Cry that have awsome graphics but needs no skill to master the gameplay (wich makes it boring,square square square)

    Leonardo "Brazil Rules", November 13, 2010 at 00:03
  2. Incredible game design. The controls are just perfect, stupid simple, engaging and challenging in a perfect balance. Gรถtt mos.

  3. Hi Jonas, just to let you know I’m going to use your game as a preloader for a game I’ve just finished (something for people to fiddle with while they’re waiting for the 5mb loading to be completed). Hope you don’t mind, of course I’ll credit you. Write me a mail if there’s an issue. Thanks!

  4. Wow! I absolutely love this game ๐Ÿ˜€ While i was going through the source, i couldn’t understand a bit.. so i thought if it’s possible for you to turn this game into tutorial? Like comment some lines and maybe rename some variables? I could learn so much from this.. Thank you ๐Ÿ™‚

  5. This is one of the best shmups I’ve played in a long time. I’m going to try to create something similar. No I can’t really understand your code but I’ll figure something out when I get done with my current project. This game fits with my sites motto “games ya wanna beat”. I have posted about it on my blog. This is right up there with graviroids . Great Job!

MGAS3FD 2: The Beginning

You have arrived at the second part of Making Games in ActionScript 3 using FlashDevelop.

Last time we got stuff setup. Not all that amusing really, just a tiny bit more setting up to go before we can get some stuff on the screen.

Continue reading

Posted in code, Making Games in Actionscript 3.0, Tutorials |
  1. (fcsh)Build succeeded Done(0) [Starting debug session with FDB] Where is the โ€hello worldโ€ text?

  2. I am getting the following error: C:\Users\Lourdes Martinez\Documents\flex_sdk_3.1.0.2710\frameworks\flex-config.xml(54): Error: unable to open ‘libs/player/10/playerglobal.swc’ Build halted with errors (fcsh). Done(1) and evidently, I’m not getting the “Hello world” message. What’s the problem?

  3. (fcsh)Build succeeded Done(0) [Starting debug session with FDB] Where is the ”hello world” text?

  4. Never mind. But the Hello World part doesn’t come up, and I did download everything needed.

  5. What? when I do the debug thing it asks if I want this AS3 context thing, if I say yes it opens and nothing happens, if I say no nothing happens. And I can’t find the ‘Hello world’ thing in the output box. Help?

MGAS3FD 1: The Setup

Welcome to the first part of Making Games in ActionScript 3 using FlashDevelop (just rolls of the tongue, doesn’t it?)

People keep asking me if I know any good tutorials for making games in Flash, and I keep answering that I don’t. Most of the one’s I’ve seen have only barely been ported from AS2, keeping the “old flash” mindset and not really making use of the new fancy stuff you can do in AS3. I think that’s a pity!

So, here’s my way of doing it.

This tutorial will assume some basic familiarity with Object oriented programming a graphical tool of your choice and general computer literacy. If anything is unclear, feel free to ask in the comments.


First, there’s some stuff we need to download:

  • The latest version of FlashDevelop (at the time of writing this was Beta9)
  • The Flex SDK (I use version 3.1.0, build 2710 but that shouldn’t matter too much)
  • A debug Flash player (I like the standalone one for development, but get the ones for the browsers too!)
  • Also, get Java 1.6+ if you don’t have it, the Flex compiler needs that

I use the Flash CS3 authoring tool to make my graphics, however, you can use any tool that can export swf’s and for the sake of completeness will show you how to use plain old png’s aswell. But the authoring tool is very hard to beat when doing animations, so consider getting it.
If you don’t have the Flash authoring there’s a trial for the CS4 version.


Start with FlashDevelop, that should be a no-brainer.
(Now would be a good time to install Java if you don’t have that)
Then extract the SDK to whatever folder you’re comfortable with, all you will need to do is to point FlashDevelop to it later, then you can forget about it altogether.
Install the debug player for your browser, FlashDevelops internal player (IIRC) will use the version you install for IE.
Finally put the standalone Flash Player in a suitable directory, it will associate itself with the proper file formats when you run it, so just drop it wherever you want it and run it once.

Starting it up.

Now, it’s time to start FlashDevelop.
You should be greeted by a nice Start Page. The first thing we will need to do is to setup where we put the Flex SDK.
Go to Tools -> Program Settings… -> AS3Context -> Flex SDK Location (see the picture) and point it to the directory where you unpacked the SDK.

And that’s it. You’re ready to go. Go get yourself something unhealthy to eat as a celebration.

Next time we get started on our first project.

Posted in code, Making Games in Actionscript 3.0, Tutorials |
  1. can i develop .swf extension game in flashdevelop ide plz mail me ans…plz…

  2. It seems they’ve taken SDK off of SourceForge. No worries, it comes with FlashDevelop.

  3. Object Oriented Programming is really useful for various reasons. The best being able to reuse code with the least effort.

  4. i know nothing about to get into this?shoul i master it like c++ etc…please help me out.i’m really curious

  5. Ditto Johnthegaylizard.

new server, new domain

I had a bit of a falling out with my old hosting provider, they essentially asked me to leave. So I took the opportunity to make the move to a new domain at the same time. All old links should redirect here and will continue doing so for the foreseeable future, but do update your bookmarks just to make sure.

If you’re reading my blog through rss you don’t need to do anything, the feedburner-feed stays at the same url.

I also updated the design a bit, it still looks absolutely horrible in ie6 though, but that’s a work in progress.

And when I’m at it, I’ve been twittering for a while and I’d like some more fun people to follow, send me a message or even follow me and I might follow you back.

Posted in News |
  1. One would hope so. I do have some stuff that could keep this place going for a while.

  2. Does this mean more regular updates?