This is a trick I picked up recently when I was preparing some games (Mashin’ Meeces and Star Fall) for release on portal sites and saw that it would be a bit easier (and required by some) to figure out how to change my multi-SWF application into a single SWF app.

Mashin’ Meeces was originally broken into three SWFs: game code, art assets and sounds. I did this so that I could work on the game independently from the sound or art since those were being taken care of by other people. Through my previous experience developing games I had never run into a problem with having games broken into multiple SWFs before but those projects have all been for private sites and game portals like Newgrounds and Kongregate are a new experience for me. After talking with my colleagues, doing some research and poking at the code for a bit I finally got the solution of embedding the SWFs into my main application and then load them using loadBytes.

Here is the code I used to embed the two SWFs (art and sounds) into the main class of my ActionScript project.

[cc lang=”actionscript3″ line_numbers=”true” no_links=”true” width=”100%”]
[SWF(width=’800′, height=’600′, backgroundColor=’0xffffff’, frameRate=’30’)]
public class MashinMeeces extends Sprite
{
[Embed(source=”MashinMeecesAssets.swf”, mimeType=”application/octet-stream”)]
private var swfAssets:Class;
[Embed(source=”MashinMeecesSounds.swf”, mimeType=”application/octet-stream”)]
private var swfSounds:Class;

public function MashinMeeces()
{
// Rawr! I am the constructor…
}
}
[/cc]

For the loading I had just been using a standard Loader implementation and to convert the pre-existing code all I had to do was drop the URLRequest() and change load() to loadBytes().

[cc lang=”actionscript3″ line_numbers=”true” no_links=”true” width=”100%”]
protected function addedToStage(in_event:Event):void
{
var loaderContext:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain);

var assetLoader:Loader = new Loader();
addChild(assetLoader);
assetLoader.visible = false;
assetLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, assetsLoaded, false, 0, true);
assetLoader.loadBytes(new swfAssets(), loaderContext);
}
[/cc]

Tags : , , , | Comments Off on Actionscript Project Refactors: Multiple Swf to Single Swf Loading

Mashin’ Meeces – Released!

Posted by aBethke on Saturday Jun 12, 2010 Under Mashin Meeces, Releases

This is a quirky but fun action game in which the player revisits the comical dynamic of mice terrorizing elephants. Users have two modes of play to choose from to better customize their experience. Free Play Mode is a more relaxed style of progression allowing the users to casually sit back and mash some mice at their leisure. Challenge Mode is for users who like something with a bit more substance. Battle your way through 10 levels of game play including the Twin Terrors and finally confront the Mama Mouse.

Play it, rate it, favourite it! at the following sites…

Kongregate
Newgrounds
Fizzy
Game Jolt

Mashin Meeces - Screenshot

Tags : , , | Comments Off on Mashin’ Meeces – Released!