Packagecom.soma.assets
Classpublic class AssetFactory

Author: Romuald Quantin - www.soundstep.com

Information:
Blog page - SomaUI
How does it work - Soma Protest
Project Host - Google Code
Documentation - Soma ASDOC
Class version: 2.0
Actionscript version: 3.0

Copyright:

The contents of this file are subject to the Mozilla Public License
Version 1.1 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.mozilla.org/MPL/

Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied.
See the License for the specific language governing rights and
limitations under the License.

The Original Code is Soma.
The Initial Developer of the Original Code is Romuald Quantin.
Initial Developer are Copyright (C) 2008-2009 Soundstep. All Rights Reserved.

Usage:
Internal class used by the NodeParser class to instantiate assets registered in the Soma global library (Soma.getInstance().library) from a XML node. Some assets are registered by default in the framework and are ready to use:

node name: bitmap creates a Bitmap instance from a bitmap in a flash IDE library (or SWC) using the linkage name.
<bitmap id="myBitmap" linkage="MyBitmapClassInLibrary" x="50" alpha=".5" verticalCenter="0" />

node name: movieclip creates a MovieClip instance from a movie clip in a flash IDE library (or SWC) using the linkage name.
<movieclip id="myMovieClip" linkage="MyMovieClipClassInLibrary" x="50" alpha=".5" verticalCenter="0" />

node name: text creates a SomaText instance.
<text id="myText" x="50" alpha=".5" verticalCenter="0" /><![CDATA[This is my text]]></text>

node name: video creates a SomaVideo instance.
<video id="myVideo" url="video.flv" x="50" alpha=".5" verticalCenter="0" volume="0" />

See also

Library
NodeParser
IAsset
ILibrary


Public Methods
 MethodDefined by
  
Creates an AssetFactory instance
AssetFactory
  
create(assetType:String, node:XML, baseUI:BaseUI = null):DisplayObject
Parse a XML node to create and return an asset registered in the Soma global library, using the type registered in the library (identifier: assetType).
AssetFactory
Constructor detail
AssetFactory()constructor
public function AssetFactory()

Creates an AssetFactory instance

Method detail
create()method
public function create(assetType:String, node:XML, baseUI:BaseUI = null):DisplayObject

Parse a XML node to create and return an asset registered in the Soma global library, using the type registered in the library (identifier: assetType). Class specific properties (such as alpha for a Bitmap) and BaseUI properties (such as horizontalCenter) will also be parsed and applied to the asset.

Parameters
assetType:String — type of the asset (string identifier used to register the asset in the library).
 
node:XML — node XML describing the asset.
 
baseUI:BaseUI (default = null) — BaseUI instance (if existing) that will hold the asset.

Returns
DisplayObject