Popular contentToday's:All time:NavigationUser login |
An evening alone with AS3 after [fotb]After coming back from flash on the beach and listening to Brandon Hall, and Keith Peters great sessions on AS3, I've been quite eager to have a play around. Personally I always find the best way to learn any new language is to make a game, and I thought my blog could also do with a little more colour, so i downloaded the FLEX 2 Beta from Adobe labs and got cracking. I wanted to make something which used the new AS3 specific features, but also some of the Flash 8 features, such as bitmaps and filters, which I have dabbled with only briefly. I while ago a made a nice little demo with some circle things that build doozer constructions into the sky, this had always suffered from a bit of slowdown once i got to a certain amount of onscreen content so I figured this would be a good base for conversion. Im also pretty excited by what Nintendo are doing with the Wii, so though i could ditch my yellow circle creatures, and paste a little homage to Mario in there. Each mario is a movieclip, this allowed me to import a animated GIF directly. To get him facing left, i just set scaleX to -1 (remembering scale has change to 0-1 for 0-100%) When you click on a character, I create several Bitmap instances, and again use the copyPixels command to create the animated exploding tiles. This time a drop shadow filter is applied to give the 2.5D effect. You can see the finished thing in banner form, on the blog http://www.freesome.com, for the banner version I use the stage.StageHeight property to detect Im in banner mode, then disable the theme tune playback until mouse over. In full screen mode, you can resize the window and refresh to make the movie fit the window. Not really a game as such, see how long you can stop them reaching the top of the screen - but i find it oddly enjoyable... I guess you just dont get enough chance to shoot Mario normally :) What did i enjoy about AS3? I love the eclipse based Flex environment. The code completion is, if anything, even better than FlashDevelop, an especially cool feature is the automatic adding of import statements. Its also a Mac native application, where as FlashDevelop is .NET only. The speed is cool - I've tested with 1000 of the little critters on screen and still found very little slowdown. Looking at some of the papervision 3D AS3 demos that are circulating on the beta list, i think we've about reached the level Atari ST/ Commodore Amiga power now.. . exciting. There isn't so much to learn. Introducing AS2 when they did was a good move by Macromedia - even if it did not change the underlying architecture it gave us lots of time to practice with the typing variables and so on. If you've been doing this for a while now, and it really does make your life simpler so there no reason not to, most of the transition work is no hassle for you. All the new import statements and re-jigging of classes and properties will take a little while, but its not so bad. For example it took me quite a while to figure out how to change the mouse pointer to a pointing hand (its DisplayObject.buttonMode = true by the way). A couple of things I found i was a little unsure which related to AS3. Different types of displayObject. We have, MovieClip, Sprite, and Bitmap classes. I'm still not one confident when to use one over the other, i'm sure i could optimize better if i did. Garbage collection. Grant Skinners articles on this subject has made me sure this is going to be a problem for many. I definitely found some some slowdown if I've got lots of exploding objects on screen. Im not sure, but this may be related to how i remove the parent objects. I need to have another read of Grants articles i think :( I found the way to load things like sound a little long winded, you need three separate classes to load a sound which seems a little excessive.. but I guess once I get all this functionality into a class of its own it will be simple, but yeah, a quick and dirty loadSound - takes six lines of code now... You can find the source here. Fisix looks greatI've downloaded the first release of Fisix, but have yet to find time to play - with Fisix and Papervision both making releases its definitely a busy time for flash game dev's. Lots to keep up with :) Ive also been trying to think through how a 2D engine like Fisix could be used with a 3D one, perhaps some kind of 2.5D Yoshi type effects? I didn't know about FD's import features, but I have not used it for AS3 dev. I'm sticking with it for AS2 work, but even with the new coherence mode of parallels, i'm still glad for the OSX Native (well osx java native) eclipse. Good laugh :)Good laugh :) Cache bitmaps?This is cool :) How come when i resize my window and do a refresh, the screen is bigger, but it doesnt slow down? Is this using the cachebitmap thing? Ali No, Bitmap classCacheBitmap turns a movieclip into a bitmap (as opposed to a collection of vectors and what-not). Im insttead creating an instance of the flash.display.Bitmap Class. As this is already a bitmap, you dont need to cacheBitmap it... Flex?So you're using Eclipse for coding with ActionScript, cool FlexWell I don't know if you knew of Flex from a couple of years ago? FLEX has been developed as an alternative way to create a Flash content. Primarily FLEX developers use an XML based language to crate UI components as opposed to the FLASH IDE, with all of tis incomprehensible (to non-designers) time lines and movieclips. Unfortunately in its first release Macromedia chose to issue it as a server based solution, along with a nice license fee of $20000. I think at that time I met only two FLEX coders, and one them was lying :) Now the situation is much better. Adobe (rip macromedia) have correctly identified that the RIA market has a very real contender in AJAX based applications. The AJAX world has a huge advantage as well in the sheer number of developers who are fluent in the technologies required. The new FLEX Builder 2, is really just a plug-in for eclipse (although it comes bundled in its own installer). This is genius on the part of Adobe, as it provides a very familiar environment for legions of JAVA developers. The code base has also changed to AS3 (although XML is used for layouts etc). AS3 is *incredibly* similar to Java or c#, and again the idea is to attract traditional developers. I mentioned layouts are created in XML - this is true, but the builder also comes with a drag and drop interface for creating these XML files. If you have ever used visualStudio you will be immediately at home with whats going on. However - none of this is the main thing for me... :) For me the key thing is that the FLEX SDK is released as FREE SOFTWARE. This is not the same as the FLEX BUILDER enviorment, but consists of free tools such as the compiler, which means that ultimately you don't need to buy FLEX Builder to create apps, you can just set up eclipse to use the free compiler. Also you dont *need* to use the FLEX component framework to create apps. This is a set of library's, that give you very simple to use UI components such as windows and slider etc... Great for RIA - but for my simple little Mario game - not required.... Instead I can just use the FLEX environment as an AS3 compiler. Which is what I did. |
And don't forget fisix
This physics engine is yet another amazing AS3 thing. Online games will certainly greatly improve thanks to the Flash 9/AS3 :)
Just FYI, FlashDevelop also has "automatic adding of import statements" ;)