A few people have asked about exporting ALPACA projects into a single .swf file - that is, without the data folder and the external music files. This could be a good option for any designers who want their games to be downloadable, or otherwise expect to move them around a bit and don’t want to deal with keeping multiple files in the right places. You won’t be able to easily change your settings, subtitles, or music after you’ve exported your game from Flash, but if that’s not a problem, this is a quick fix.

I’ll outline a quick-and-dirty method below. Look for the next ALPACA release to include a cleaner way to do this.

  1. Create your ALPACA game as you normally would - use external files for your config settings, dialog, and background music. Check out my earlier tutorials if you're new to this part.
  2. Once your game is ready to be published, import your background music (if you're using it) into your Flash project. Open its properties, export it for Actionscript, and give it the Class name bgMusic. If you're not using music, skip to step 6.
  3. Open Muzak.as. At the top of the file, under all the import commands, add this new one: import flash.utils.getDefinitionByName;
  4. Replace the following line in public function Muzak: music = new Sound(new URLRequest(musicURL)); With these lines: var musicID = getDefinitionByName("bgMusic"); music = new musicID;
  5. Test your project and make sure the music still works. If it sounds funny, you may want to play with Flash's audio export settings, since Flash is now compressing it.
  6. Now open up Engine.as.
  7. In the startGame function, replace the following lines: // Load external configuration data var jsURL = new URLRequest("data/config.js"); configLoader = new URLLoader(jsURL); configLoader.addEventListener("complete", configLoaded);// Load all spoken lines jsURL = new URLRequest("data/speechlines.js"); speechLoader = new URLLoader(jsURL); speechLoader.addEventListener("complete", linesLoaded); With these ones: configLoaded(new Event("filler")); linesLoaded(new Event("filler"));
  8. Just below this function is the linesLoaded function. Replace the one line inside the brackets with these two: var jsonLines:String = ''; linesData = JSON.decode(jsonLines);
  9. Now open up speechlines.js. You're going to need to put the entire contents of this file between those two empty quotes in var jsonLines:String = ''. But first, we need to eliminate the line breaks and escape the punctuation. I put together a simple web tool that will do this for you. Copy the entire file, paste its contents into the input box, and hit the Convert button. Copy the result, and then paste it between the empty quotes. Make sure the whole thing is one solid string, with no breaks in it.
  10. Finally, let's fix the configLoaded function. You can copy your external file into a string, like we just did, if you want. However, you might find it easier to simply delete the line that reads configData = JSON.decode(configLoader.data); and then replace the value for each of the following lines with their data from your config file.  Just remember to use Actionscript syntax now. Here's a sample: useAudio = true; playerScale=1; walkRate=15; targetBuffer = 20; playerName = "Player"; firstLocation="firstroom"; saveID = "alpacasample"; You can ignore the gameURL, musicURL, endMusicURL, saveURL, and thisVersion variables, since they no longer apply.
  11. One last thing, if you are using an external music file for your ending screen: scroll all the way down to the endGame function. Delete this line: options.changeMusic(endMusicURL); You can import the music into the Flash project and put it in your ending movie clip manually.

And that’s our (relatively) quick method. Like I said, the next ALPACA release will include a better way to do this, by making the config and speechlines data into their own classes. Feel free to report any issues or ask questions in the comments.