Français:Assets Package

TRANSLATION PENDING

Overview
com.gaiaframework.assets The Assets package uses the Abstract Factory, Composition and Proxy design patterns. As Assets are loaded, they are assigned to dynamically generated clips (more information about this is found in the Core SiteController class), and the classes provide proxy commands directly to the assets themselves for easy development. Assets also provide a way to bypass the proxy for those who need it.

While the Asset classes all contain public methods, their core methods are only meant for use by the Gaia framework. Only the proxy and getter methods are meant for developer use.

In AS3, the interface classes for the assets are the preferred method for accessing them, as they prevent access to the internal methods.

AssetCreator
This is a factory class that determines which concrete Asset to instantiate based on the file extension or type attribute of the asset. The SiteModel (in the core package) uses the AssetCreator factory when it is parsing the site.xml.

AbstractAsset
This is the abstract class for all concrete Asset classes. This class keeps track of whether the asset is in the active branch, the id, src, and title of the asset, as well as containing the universal loading, progress and complete events for all assets.

Display Assets
The following assets are visible assets.

DisplayObjectAsset (AS3 Only)
This concrete asset is the base class for all assets that extend DisplayObject in AS3. It provides a proxy to access all relevant native DisplayObject properties and methods. If you need to target the DisplayObject directly, you can do so through the public get content method. You can also access the Loader instance directly, as well, by using the get loader method.

BitmapAsset (AS3 Only)
This concrete asset is used for images in AS3. It provides a proxy to access all relevant native Bitmap properties and methods. If you need to target the Bitmap directly, you can do so through the public get content method. If you want to add interactivity, use the BitmapSpriteAsset.

BitmapSpriteAsset (AS3 Only)
This is a Bitmap that has been wrapped in a Sprite and the asset provides a proxy to that Sprite, so you can add interactivity directly to the asset. Check the Site XML documentation for more information on how to create BitmapSpriteAssets.

SpriteAsset (AS3 Only)
This concrete asset is used for swfs and images. It provides a proxy to access all relevant native Sprite properties and methods. If you do not need to access the MovieClip methods in IMovieClip, use ISprite to save file size. It extends DisplayObjectAsset.

MovieClipAsset
This concrete asset is used for swfs in AS3 and also images in AS2. It provides a proxy to access all relevant native MovieClip properties and methods. If you need to target the MovieClip directly, you can do so through the public get content method. In AS3, it extends SpriteAsset.

PageAsset
This concrete asset inherits from MovieClipAsset and is used for pages in the framework. This class manages page specific activity, including transitioning, events, and destroying its assets when it is removed from the active branch. Pages have a get branch getter method which returns the page's branch via Chain Of Responsibility and Composition, calling up its parent branch to the base of the tree.

Pages have other public properties, some of which you should feel free to access, some of which you shouldn't unless you know what you're doing! In AS3, use the IPageAsset interface. Having a good understanding of the way the SiteController works is a recommended prerequisite before you start changing page properties. The primarily useful public properties are getParent, children, flow, defaultChild and, in AS3, assetArray.

getParent
This method returns the page's parent PageAsset.

children
A hash of its children Pages (stored by their id).

flow
The page flow can be changed at runtime if you need to do so.

branch
The page's branch is read-only

defaultChild
This is set to the first child of the Page from the site.xml structure by default. You can set this during runtime. One good use for this is if an intro page is the first child of a Page and you want to not go back to the intro from then on if you navigate to the intro page's parent page, you can set the parent's defaultChild to another of its children. This is also helpful during development if you want Gaia to go straight to a specific child.

assetArray (AS3 only)
Returns an array of the assets in the order they are listed in the site.xml. This getter creates the array on the fly every time in order to support dynamically added assets, so make sure you store a reference to it when iterating through it, otherwise you will be recreating the Array every iteration - not good! AS2 does not need this because for...in assets works fine.

Example usage in your page document class: var assetArray:Array = page.assetArray; var len:int = assetArray.length; for (var i:int = 0; i < len; i++) {    trace(assetArray[i]); }

Media Assets
The following are the assets for media, such as Sound and Video.

NetStreamAsset
This concrete asset loads FLV and M4A files. It creates a new NetConnection and NetStream, and provides proxy methods to the NetStream. The NetStream instance is available directly through the get ns method. In AS3, there are volume fading and panning methods, as well.

SoundAsset
This concrete asset is used for wav and mp3 files. It automatically takes care of setting up a Sound object and, like the other concrete Assets, provides a proxy to the native Sound object methods. You can bypass the proxy through the get sound getter method. It also has fading and panning scripts.

SoundClipAsset (AS2 Only)
This concrete asset extends SoundAsset and is used for swf files that are set up to play an attached Sound object. It automatically takes care of accessing the Sound object and, like the other concrete Assets, provides a proxy to the native Sound object methods inside the loaded clip. You can bypass the proxy through the sound property.

Data Assets
Data Assets include xml, style sheets and text.

XMLAsset
This concrete asset loads XML. You can access the raw xml using the xml proeprty, or use the obj property to get an XML2AS object of the XML. Information about XML2AS can be found on google. I prefer XML2AS over XPath, and since I use it all the time, I've included it in the class. In AS3, the xml property is used in tandem with E4X, and also extends TextAsset.

StyleSheetAsset
This concrete asset is used for css files. It contains a proxy for all the methods available to the StyleSheet class in both AS2 and AS3. In AS3, it extends TextAsset.

TextAsset (AS3 Only)
This concrete asset is the base class for XMLAsset and StyleSheetAsset and can be used to load in plain text files. You can access it by using the text property.