Start learning with our library of video tutorials taught by experts. Get started
Viewers: in countries Watching now:
Join Lee Brimelow in this project-style course that teaches how to build a Flash-based game with Flash Builder 4.6, Flash Player 11, and the Starling framework. Starling, a pure ActionScript 3.0 library for advanced graphics, extends Flash Player 11's support for the modern GPU (graphic processing unit) to enable visual presentations and games in the browser or as a mobile app.
Starting with installation and configuration of Starling and creation of a Flash Builder project, the course shows how to prepare and import graphical assets, create MovieClip classes from sprite sheets, manage various gaming objects, detect collisions, and add both particle and sound effects. The finished game can be deployed to any browser or mobile device that integrates Flash Player 11, which was released in September 2011.
So now we have our basic game play completed. So we have our collisions happening and we determined when we're going to go to the GameOver state. But now we need to clean up after ourselves in the play state. So we need to implement the destroy methods. So first, let's go to our BulletManager. So in our Manager classes, we need to do a couple of things in the destroy method. First, we're going to destroy the pool. So to do that, we're going to call the destroy method of the pool. Then we're going to set pool = null and we're also going to set our array to null.
So our array here is called bullets, and we'll set it equal to null. When it comes to cleaning up after yourself and garbage collection in Flash, it's better to do too much than not enough. So it's somewhat of a mystery sometimes about how to force things to be reclaimed in memory, so it's better just to go overboard and just be sure that you're cleaning up after yourself. So we're going to copy this because we're going to do a similar thing in the AlienManager class. I am going to come down to the destroy method, paste that in, and obviously our array here is called aliens.
Now we want to go to our play method, and implement the destroy method here. Now what I'm going to first do is to copy these two event handlers where we listen for the mouse up and mouse down, and let's go ahead and make sure that those are actually unregistered. So we'll do that first. We'll change that to removeEventListener. Now we're going to call those destroy methods on the BulletManager and the AlienManager. So bulletManager.destroy(); and then alienManager.destroy(), and then lastly let's remove this play state from the display list of our game.
So we're going to say removeFromParent and we're going to pass in (true) to dispose it. Now let's go ahead and test it, so I'm going to debug. We'll go to our actual game. So everything is working and now when I die, we actually remove the play state and now here is the GameOver state. Obviously, we haven't done anything yet in the GameOver state, but we'll be doing that in the next chapter.
There are currently no FAQs about Building Flash Games with Starling.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.