Posts Tagged ‘ActionScript3’

  • AS3 to TypeScript Conversion Script

    AS3 to TypeScript

    I write a lot of HTML5 games and my preferred language of choice is TypeScript. I love the compile-time errors, code-insight and debugging tools it provides. A large part of my work is porting over ActionScript3 code from Flash games. I found that I was going through the same motions over and over again; simple things like changing “Boolean” to “bool”, or rename the class function to “constructor”.

    It got to the point where I figured it would save time to write a script to help with the process. So I did, and I’ve released it for anyone else who may benefit from it. The script runs on a local web server and can convert either a single file or a whole directory full of them. It will intelligently deep-scan a folder structure, converting just the ActionScript files that it finds along the way. I’ve successfully run it across the whole of the flixel codebase with no issues, so I’m hopeful it’ll work for you.

    It uses a set of 20 conversion tasks, but the list is easy to modify and extend. Indeed if you create new ones (or optimise some of my sucky regexps!) to the benefit other devs then please share them so I can update the script.

    Be under no illusion about the amount of work you’ll still have to do once the conversion has run. Properties, vars, native Flash objects and lots of other things will still need fixing and changing by hand. But at least a huge volume of the tedious grunt work will be out of the way. And if it saves you as much time as it has  me then that’s just a bonus in my books.

    Grab the AS3 to TypeScript Converter from github.

  • Access LiveDocs locally with Doc v3.0.1

    Although the code-insight features of FlashDevelop help a lot, you can’t beat a good AS3 reference – and I use Adobe LiveDocs almost exclusively for this. Although I have a Firefox search plugin that gives me quick access to it, I have still always wanted a decent local copy that offered the same benefits my browser does, but faster.

    Thanks to the magic of Twitter (cheers @kode80) today I found such a beast in the shape of an AIR app called Doc?

    Doc? allows you to view, search and bookmark all your favourite ASDocs. But the biggest feature for me is that on-line docs can be downloaded and stored locally too. This means that the docs for things like Away3D, Flint, Papervision, Adobe CoreLib, TweenMax or anything else that has ASDoc documentation can be added to your local books collection.

    Adding a remote ASDoc

    Adding new books couldn’t be more simple. Just start-up Doc?, click the settings icon in the top-right and select “”Add Remote ASDoc”. You’ll be asked for some details. Here they are for the Stardust Particles system:

    Note: when adding URLs be sure to specify a directory, and don’t have the index.html on the end.

    Doc? will then download and index the files, storing them locally.

    Be advised that on large sets of documentation this can take a while. Indexing the AS3 Language Reference took nearly 10 minutes, and that’s on an Intel Quad Core Q9950 @ 2.83GHz with 8GB RAM. Doc? stores the indexes in a local SQLite database.

    Once downloaded and indexed the docs are available from the Books menu, ready for easy and fast local searching!

    Here you can see I searched for “Radius” specifically in the Stardust book, and am viewing the CollisionRadius page. You can search across all books, highlight results in the text, include title and/or content in the search and even bookmark sections you know you return to often.

    The tree view display has icons depending on the style of result – the green “C” circle icon means it’s a Class, but it also shows packages, methods, constants, interface and others.

    AS3 Language Reference

    One of the first things I recommend you do is download the ActionScript3 Language Reference zip from the Adobe web site (5.8MB). Unzip it somewhere and use the “Add Local Book” Settings option to add it. It will still need to be indexed (and this takes a long time), but it’s better to grab the zip as it can often have more up to date docs vs. those installed with CS4.

    I’m quite sure that this app will save me a lot of time vs. digging through browser bookmarks.

    Visit the Doc? web site

    All I’d like to see now is this built into FlashDevelop, so F1 searched within Doc? 🙂

  • New Amiga Mod / Soundtracker AS3 Replay Library

    In the immortal words of the BudBrains: Check dis out:

    [swfobj src=”http://sandbox.photonstorm.com/flod/FlodDemo1.swf” width=”426″ height=”426″]

    Now Amiga mod replay has been done in AS3 before, most famously by Joa and Andre in the 8BitBoy Popforge library. And more recently in Flash Mod Player by Badsectoracula (although that is written in haXe it still compiles to AS3). But today I was blown away to receive a tiny zip package from the talented Christian Corti, lead developer at TrinityEffects. It contained a little test swf and a few class files named “flod”.

    Flod is his native AS3/FP10 Amiga Module playing library. And as you can hear, it plays very well!

    It has full support for 15/31 instruments and all the effects up to Protracker 2.3 including Inverse Loop (latest version, not the Funky Repeat), it also supports both Amiga A500 and A1200 filters. It adds less than 10Kb to your SWF file size (excluding the mod itself of course), but more importantly the CPU impact is minimal.

    Christian has released it under the Creative Commons Attribution-Share Alike 3 (Unsupported) License, which basically means you are pretty much free to use it however you want, for whatever you want. It requires Flash Player 10, which at it’s current adoption rate of 76% and growing, shouldn’t be a big issue for anyone these days.

    I fully intend to integrate this with the FP10 branch of PixelBlitz. He also has a set of SoundSpectrum classes for generating beautiful VU meters (and also extremely useful if you wish to link the music to in-game events or effects). They are being tidied up at the moment, so hopefully they’ll be released soon. I’ll post about it here when they are.

    Feel free to download the zip file and have a play!

    Please comment here to let us both know what you create with it.

  • SourceBinder – pure AS3 awesomeness!

    SourceBinder

    Quite out of the blue I received an invite to the SourceBinder project tonight. I honestly couldn’t even remember what it was, but after a couple of minutes playing I was hooked!

    If you are experienced with node based creation tools, like FilterForge for example, then you’ll have a good idea what this is about. Basically it’s an FP10 visual creation tool – you can create your own nodes (or use many of the public ones up there) and chain them together to create stunning visual effects. Loads of libraries are built in already like JigFlashLib, Tweener, Flint and PV3d, so nodes can be created using these.

    SourceBinder Example

    Nodes can perform tasks such as colour changing, mouse input, sound handling, PV3D creation and loads more. They are simple AS3 classes (which you can edit live online). You chain them together using a neat drag and drop interface, the final “display renderer” node being responsible for the output.

    It’s just great – I urge you to try it!

    http://sourcebinder.org

  • Fruiti Blox finished, and thus ends a year of AS3 learning

    Fruiti Blox Title Page
    Today I delivered the final source files to Candystand.com for my latest game Fruiti Blox. They should be releasing it in January 2009, so I’ll write again when it’s live for playing, but it was a great experience for me and they were fantastic people to work with. I can’t wait to see the game live.

    Oddly enough today also marks the first anniversary of my journey into AS3 and Flash. It was a year ago today (back in 2007) that I started teaching myself AS3. I had never touched a single line of ActionScript in my life before. All of the AS2 code I saw scared the hell out of me, the sheer mess of it really went against my coding OCD! But AS3 was different. It was familiar, and powerful. I armed myself with Moock’s Essential AS3 bible, the AS3 Cookbook, a copy of Flash CS3 and set to work.

    The journey has been incredible. I’m no stranger to programming, especially not games development, but I honestly have not had this much development fun for many many years. I’ve always said that limitation breeds creativity (a true mantra of the demo scene), and I found the limitations of Flash were what drew me in, but the sexiness that is AS3 captivated me and never let go.

    My first ever game was called “Go Fish”, and it involved making a fish swim through an ever encroaching sea cavern. It taught me a lot about how AS3 worked, in particular how it handled bitmaps and mouse events, and the whole process of screen updating. Collision detection was ropey (at best), the graphics chunky and I stupidly set the frame rate at 60 fps. But it was a start.

    From there I moved onto a few small demo effects, porting over my old DarkBASIC code into AS3. Starfields, morphing balls, sine-waves, that kind of thing. Seeing these effects come alive in my browser was awesome. It was like meeting an old friend you haven’t seen for ages.

    By this point we were into the middle of January, and I wanted to create a game for one of the web sites we look after at work. I figured it needed to be quite simple as it was my first Flash game project, so I kicked off with a “match 2 cards” affair. The end result was Match Quest for the Shaun the Sheep web site. I did all the visuals and code myself. I was so green to Flash in general that I didn’t realise that you could set an image in the library to use say 80% compression and that it would still retain alpha levels (I figured it’d convert it into a jpeg and loose all alpha, like a browser does). This meant the game was massive, over 2MB in size 🙂 so large I even wrote a pre-loader “space invaders” game for people to play as it loaded! But it was the first rung of the ladder for me, and I was pleased.

    From there I moved almost directly onto my next game Colour Chain and it was released one month later. It was another puzzle game, this time involving more arcade style effects (nice particle trails, exploding blocks, etc) and yes – sound effects! (Match Quest is utterly devoid of any sound). People genuinely loved this game, and it’s played by thousands of people across the web still today. Something that amazes me.

    Fruiti Blox in-game

    I was now in my element and learning at an extremely rapid pace. I won’t bore you with a complete chronology of events for the year, but suffice to say we’re now 12 months from that infamous day and my coding life is a much richer and different place because of it. I wanted to release 12 games within one year, and I sort of failed to do this – I actually released 10. I guess if you include the early Go Fish and the Space Invaders pre-loader game then I coded 12, but I’m not one for cheating 🙂

    Aside from the coding I’m really amazed at the Flash game developer community. I have met some truly great people this past year, not least of which include the dynamic duo over at 8-bit Rocket; quite frankly we’re like UK/US carbon copies of each other given our loves and pasts! Also a quick shout to squize / GYM. A total ActionScript powerhouse if ever there was one, a truly awesome coder, and dude your tenacity at capturing all Xbox achievements scares the hell out of me. Do you secretly own all Pokemon beasts? Also the great people on FlashGameLicense.com (both running it and using it), and the sponsors I’ve met as a result. FGL believed in my games, which lead to real world cash, which lead to utter surprise and amazement from me 🙂 Full respect for all they do.

    So what does the future hold? Right now I’ve got 3 days left at work before I leave for Christmas, and I’m not back in there until January 5th 2009. I’m busy coding a MMO Flash based virtual world for a client, which is a whole new set of challenges believe me! This should see release in March 2009, and it will take up most of my commercial development time. But of course I’ll still be building games “for fun” as well. I have a number of ideas fleshed out on paper, one of which is well into production with art assets already underway. One thing I am determined to do is move away from puzzle games next year and focus more on action and arcade titles. Right now the game in production is a top-down shooter similar to Alien Breed / Gauntlet. So it’s requiring a mass of new technologies for me, and PixelBlitz is going to get some serious updates in the process.

    There’s still a few weeks left until 2009 but I’m going to take them off, away from games coding and instead spend extra time with my family, read some books and hopefully finally complete Puzzle Quest on my 360. The stack of books I have here should interest a lot of you reading this blog, so I’ll write about them later on. Until then I hope you all have a great Christmas / Holiday season, and look forward to seeing what 2009 will bring us all.