The Resource Manager

From Web-Adventure-Kit-Wiki

Jump to: navigation, search

In order to get a single swf as the final output from a WAK project. We embed all the assets or resources (from now asset or resource are used as synonyms) inside the WAK project, so they are compiled within the swf. To do such thing in Actionscript 3 using the flexSDK compiler you must use the “Embed” meta data, to avoid the maintenance of the embed assets and to be able to manage some assets id WAK uses its own resource manager. Which is only a single tool to manage in a comfy way the creation of a class where all the assets of a project are embed and assigned to certain identification name. This tool creates two output files:

Resources.as : Which is an Actionscript class containing all the embed meta-data and vars.

ResourcesManifest.xml : Which is an XML used only by the tools included in WAK.


If you didn't do it yet, install the resource manager tool included in the WAK latest release called ResGenerator.air and then open it. This is the first you are going to see.


Image:ResGenSnap.png


1 – The first thing you have to do is to tell to the ResGenerator on which project you are going to work. Click in the File menu and select Open.

2 – Browse to the folder where you set your WAK project from the skeleton project in the “Getting Started” tutorial and select the file ResourcesManifest.xml.

3 – After you open the resource manifest of the project, deploy the Images folder in the tree and you should see something like this:

Image:ResGenOpen.png


Adding new resources to the project.

You will need to add more assets to your project in order to create a great adventure, so this is the first step. To add a new asset, just deploy the section of the tree where the asset belongs and click “Add new”. The resource tree has the following sections:

Images: For anything being a supported bitmap format by Actionscript 3 (jpg, png, gif).

Sprites: This is the same that flash know as an Sprite, any MovieClip symbol (the flash concept of symbol not the MovieClip class) with just one frame on its timeline.

MovieClip: a flash MovieClip with an animation or more than one frame on its timeline.

Sounds: Assets for music and sound effects in mp3.

Fonts: Truetype fonts files to embed fonts in the project.

XMLAssets: Are any kind of XML to embed, you probably shouldn't touch this for your project, these are all the XML files embed into the WAK project used to set your adventure. If you deploy this section of the tree you should see several files already there.

When you click over an asset you will see three text fields displaying information of that asset. These are: Asset id: is the name or identification of this asset. This is how the asset will be known and used inside your WAK project. This name is taken from name of the file or the symbol, depending on the type of asset. So name your assets carefully, don't use anything that could cause an error when compiling Actionscript for example, avoid spaces, minus signs and things like that as separators use the underscore instead when you name your assets.

Source: is the relative path to the asset's file.

Symbol: is the name of the symbol in the case of an asset embed inside an SWF, for example if this was exported inside a swf using flash authoring tool.

There is another field called Package which is optional, and you can use it to export the Resources.as class inside some special package structure.

Once you finished adding the assets for your project click the button “Generate ResourceManager” this has a double effect. On one hand it will generate the two files mentioned before, Resources.as and ResourcesManifest.xml and on the other one it will work as a “Save” so the next time you use the ResGenerator you will open the ResourcesManifest.xml file. Now go back to your IDE or actionscript compiler and rebuild your project to include the new fresh assets into your project.