Italiano:Pacchetto Assetti

TRANSLATION PENDING

Panoramica
com.gaiaframework.assets

Il pacchetto Assets usa Abstract Factory, Composition e Proxy design patterns. Quando gli Assets sono caricati, sono assegnati alle clip generate dinamicamente (ulteriori informazioni a riguardo sono situate nella classe Core SiteController), e le classi danno comandi proxy direttamente agli assets stessi per un facile sviluppo. Assets ha un modo per bypassare il proxy per coloro che ne avessero bisogno.

Poiché le classi Asset contengono tutte metodi pubblici, i loro metodi principali sono intesi a solo uso dal framework Gaia. Solo i proxy e i metodi getter sono intesi per gli sviluppatori.

In AS3, le classi interfaccia per gli assets sono i metodi preferiti per accedervi, poiché prevengono l'accesso ai metodi interni.

AssetCreator
Questa è una classe Factory che determina quali asset concreti istanziare basato sull'estensione del file o sull'attributo "type" dell'asset. Il SiteModel (nel pacchetto base) usa l'AssetCreator factory quando esegue il parsing di site.xml.

AbstractAsset
Questa è la classe astratta per tutte le classi concrete Asset. Questa classe tiene la traccia se l'asset è nel ramo attivo, l'id, src, e title dell'asset, nonché contiene gli eventi universali loading, progress and complete per tutti gli assets.

Display Assets
I seguenti sono assets visibili.

DisplayObjectAsset (Solo AS3)
Questo asset concreto è la classe base per tutti gli asset che estendono DisplayObject in AS3. Dispone di un proxy per accedere a tutte i metodi e proprietà native DisplayObject. Se dovete mirare al DisplayObject direttamente, lo potrete fare attraverso il metodo pubblico get content. Potrete anche accedere all'istanza Loader direttamente, anche usando il metodo get loader.

BitmapAsset (Solo AS3)
Questo asset concreto è usato per le immagini in AS3. Dispone di un proxy per l'accesso a tutte le proprietà e metodi della nativa Bitmap. Se avete necessità di mirare a Bitmap direttamente, lo potrete fare attraverso il metodo get content. Se volete aggiungere interattività usate il BitmapSpriteAsset.

BitmapSpriteAsset (Solo AS3)
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 (Solo AS3)
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 (Solo AS3)
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 (Solo AS2)
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 (Solo AS3)
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.