| Package | gs.model |
| Class | public class Model |
<?xml version="1.0" encoding="utf-8"?>
<model>
<fonts>
<font libraryName="Arial_Test" inSWF="fonts" />
<group id="myGroup">
<font libraryName="Helvetica Neueu Bold Condensed" />
</group>
</fonts>
<assets>
<asset libraryName="clayBanner1" source="clay_banners_1.jpg" preload="true" />
<asset libraryName="clayBanner2" source="clay_banners_2.jpg" />
<asset libraryName="clayBanner3" source="clay_banners_3.jpg" forceReload="true" />
<asset libraryName="clayWebpage" source="clay_webpage.jpg" />
<asset libraryName="rssFeed" source="http://codeendeavor.com/feed" forceType="xml" />
<asset libraryName="fonts" source="fonts.swf" preload="true" />
<group id="sounds">
<asset libraryName="thesound" source="sound.mp3" path="sounds" />
</group>
</assets>
<captions>
<group id="spiritVideo">
<caption time="3" duration="3" bgcolor="0x222222">
<![CDATA[
<span class="body">bob lob law</span>
]]>
</caption>
<caption time="8" duration="3" bgcolor="0x222222">
<![CDATA[
<span class="body">bob lob law</span>
]]>
</caption>
</group>
</captions>
<links>
<link id="google" url="http://www.google.com" />
<link id="rubyamf" url="http://www.rubyamf.org" />
<link id="guttershark" url="http://www.guttershark.net" window="_blank" />
<link id="googleFromStringId" stringId="googleInStrings" />
</links>
<attributes>
<attribute id="someAttribute" value="the value" />
<attribute id="someAttributeFromStrings" stringId="someAttributeValueStringId" />
</attributes>
<textAttributes>
<attribute id="myTextAttribute1" autoSize="left" antiAliasType="advanced"
styleSheetId='someStyleSheetId' textFormatId='someTextFormatId'
stringId='someStringId' wrapInBodySpan='true' selectable='false' border='false'
multiline='false' embedFonts='true'
/>
<attribute id="myTextAttribute2" styleSheetId='someStyleSheetId' /> <!-- you don't have to use every attribute, it will only apply what's here. -->
</textAttributes>
<services>
<http>
<service id="google" url="http://www.google.com/" retries="1" timeout="1500" >
<call id="home" url="" method="GET||POST" responseFormat="text" retries="1" timeout="1500" />
</service>
<service id="codeendeavor" url="http://www.codeendeavor.com/" retries="1" timeout="1500" >
<call id="article814" url="archives/814" method="GET||POST" responseFormat="text" retries="1" timeout="1500" />
</service>
</http>
<remoting>
<service id="amfphp" gateway="http://guttershark_amfphp/gateway.php" encoding="3" timeout="3000" retries="1" >
<call id="Echoer.echoString" endpoint="Echoer" method="echoString" />
<call id="Echoer.echoObject" endpoint="Echoer" method="echoObject" encoding="3" timeout="3000" retries="1" />
</service>
</remoting>
<soap>
<service id="resolveIP" wsdl="http://ws.cdyne.com/ip2geo/ip2geo.asmx?WSDL" timeout="3000" retries="1" />
</soap>
</services>
<security>
<policyfiles>
<crossdomain url="http://www.codeendeavor.com/crossdomain.xml" />
</policyfiles>
<xscript>
<domain name="macromedia.com" />
<domain name="\ />
<domain name="192.168.1.1" />
</xscript>
</security>
<stylesheets>
<stylesheet id="colors">
<![CDATA[
.pink {
color:#FF0066
}
]]>
</stylesheet>
<stylesheet id="colors2">
<![CDATA[
.some {
color:#FF8548
}
]]>
</stylesheet>
<stylesheet id="colors3" mergeStyleSheets="colors,colors2" />
</stylesheets>
<textformats>
<textformat id="theTF" font="Arial" color="0xFF0066" bold="true" />
</textformats>
<properties>
<-- See examples/model_properties for more information on cast types. -->
<clip x="[int]10" y="[int]10" alpha="[number]1">
<clip2 x="[int]0" y="[int]0" alpha="[number]1" />
<clip3 x="[int]200" y="[int]0" alpha="[number].5" visible="[bool]false" />
</clip>
</properties>
</model>
Examples are in the guttershark repository.
| Property | Defined by | ||
|---|---|---|---|
| assets : XMLList
Stores a reference to the
<assets></assets>
node in the model xml. | Model | ||
| attributes : XMLList
Stores a reference to the
<attributes></attributes>
node in the model xml. | Model | ||
| captions : XMLList
Stores a reference to the
<captions></captions>
node in the model xml. | Model | ||
| fonts : XMLList
Stores a reference to the
<fonts></fonts>
node in the model xml. | Model | ||
| id : String
The id of this model.
| Model | ||
| links : XMLList
Stores a reference to the
<links></links>
node in the model xml. | Model | ||
| security : XMLList
Stores a reference to the
<security></security>
node in the model xml. | Model | ||
| services : XMLList
Stores a reference to the
<services></services>
node in the model xml. | Model | ||
| strings : Strings
A placeholder for an instance of a Strings
object.
| Model | ||
| stylesheets : XMLList
Stores a reference to the
<stylesheets></stylesheets>
node in the model xml. | Model | ||
| textAttributes : XMLList
Stores a reference to the
<textAttributes></textAttributes>
node in the model xml. | Model | ||
| textformats : XMLList
Stores a reference to the
<textformats></textformats>
| Model | ||
| xml : XML
The XML used as the model.
| Model | ||
| Method | Defined by | ||
|---|---|---|---|
|
addPath(pathId:String, path:String):void
Add a path to the model.
| Model | ||
|
allowCrossScriptingDomains():void
Allows a domain for cross scripting this swf.
| Model | ||
|
applyProperties(obj:*, xml:*):void
Apply a hierarchy of property values to an object.
| Model | ||
|
attrAsBool(attributeID:String):Boolean
A shortcut method to get an attribute as a boolean.
| Model | ||
|
attrAsInt(attributeID:String):int
A shortcut method to get an attribute as an integer.
| Model | ||
|
attrAsNumber(attributeID:String):Number
A shortcut method to get an attribute as a number.
| Model | ||
|
clearCache():void
Clears the internal cache.
| Model | ||
|
dispose():void
Dispose of this model.
| Model | ||
|
doesLinkExist(id:String):Boolean
Check whether or not a link is defined in the model.
| Model | ||
|
[static]
Get a model instance.
| Model | ||
|
getAssetByLibraryName(libraryName:String, prependSourcePath:String = null):Asset
Get an Asset instance by the library name.
| Model | ||
|
getAssetGroup(groupId:String):Array
Get an array of asset objects, defined by a group node.
| Model | ||
|
getAssetsByLibraryNames(... libraryNames):Array
Get an array of asset objects, from the provided library names.
| Model | ||
|
getAssetsForPreload():Array
Returns an array of Asset instances from the assets node,
that has a "preload" attribute set to true (preload='true').
| Model | ||
|
getAttribute(attributeID:String):String
Get the value from an attribute node.
| Model | ||
|
getCaptionsByGroupId(groupId:String):*
Returns a captioning set for flv captioning.
| Model | ||
|
getColorAs0xHexString(selector:String):String
Get a color in hex with 0x, (0xff0066).
| Model | ||
|
getColorAsInt(selector:String):int
Get's a color defined in the "colors" stylesheet.
| Model | ||
|
getColorAsPoundHexString(selector:String):String
Get a color in hex with #, (#ff0066).
| Model | ||
|
getHTTPCallById(serviceId:String, callId:String):HTTPCall
Get an HTTPCall instance by id.
| Model | ||
|
getHTTPServiceById(id:String):HTTPService
Get an HTTPService by id.
| Model | ||
|
getLink(id:String):URLRequest
Creates and returns a URLRequest from a link node.
| Model | ||
|
getLinkWindow(id:String):String
Get the window attribute value on a link node.
| Model | ||
|
getPath(... pathIds):String
Get a path concatenated from the given pathIds.
| Model | ||
|
getRemotingCallById(serviceId:String, callId:String):RemotingCall
Get a remoting call by service, and call id.
| Model | ||
|
getRemotingServiceById(id:String):RemotingService
Get a remoting service by id.
| Model | ||
|
getSoapServiceById(id:String):SoapService
Get a soap service by id.
| Model | ||
|
getStyleSheetById(id:String):StyleSheet
Get a StyleSheet object by the node id.
| Model | ||
|
getTextAttributeById(id:String):TextAttributes
Get a text attributes.
| Model | ||
|
getTextFormatById(id:String):TextFormat
Get a TextFormat object by the node id.
| Model | ||
|
isPathDefined(path:String):Boolean
Check whether or not a path has been defined.
| Model | ||
|
load(model:String, complete:Function, ioerror:Function = null, securityerror:Function = null):void
Load an xml file to use as the model xml.
| Model | ||
|
loadPolicyFiles():void
Loads all the security policy files
specified in the model.
| Model | ||
|
mergeStyleSheetsAs(newStyleId:String, ... styleIds):StyleSheet
Merge any number of style sheets declared in the model as a new
stylesheet with a unique id.
| Model | ||
|
navigateToLink(id:String):void
Navigates to a link.
| Model | ||
|
registerFonts(groupId:String = null):void
Register declared fonts from the model.
| Model | ||
|
[static]
Set a model instance.
| Model | ||
|
traceFonts(groupId:String = null):*
Traces information about fonts that will be registered when calling
the registerFont method.
| Model | ||
|
unset(id:String):void
[static]
Unsets (deletes) a model instance.
| Model | ||
| Method | Defined by | ||
|---|---|---|---|
|
checkForXML():void
Check that the model xml was set on the singleton instance before any attempts
to read the xml happens.
| Model | ||
| assets | property |
public var assets:XMLList
Stores a reference to the <assets></assets>
node in the model xml.
| attributes | property |
public var attributes:XMLList
Stores a reference to the <attributes></attributes>
node in the model xml.
| captions | property |
public var captions:XMLList
Stores a reference to the <captions></captions>
node in the model xml.
| fonts | property |
public var fonts:XMLList
Stores a reference to the <fonts></fonts>
node in the model xml.
| id | property |
public var id:StringThe id of this model.
| links | property |
public var links:XMLList
Stores a reference to the <links></links>
node in the model xml.
| security | property |
public var security:XMLList
Stores a reference to the <security></security>
node in the model xml.
| services | property |
public var services:XMLList
Stores a reference to the <services></services>
node in the model xml.
| strings | property |
public var strings:StringsA placeholder for an instance of a Strings object. This is never set automatically, it's a placeholder to you to set it yourself.
| stylesheets | property |
public var stylesheets:XMLList
Stores a reference to the <stylesheets></stylesheets>
node in the model xml.
| textAttributes | property |
public var textAttributes:XMLList
Stores a reference to the <textAttributes></textAttributes>
node in the model xml.
| textformats | property |
public var textformats:XMLList
Stores a reference to the <textformats></textformats>
| xml | property |
xml:XML [read-write]The XML used as the model.
Implementation public function get xml():XML
public function set xml(value:XML):void
| addPath | () | method |
public function addPath(pathId:String, path:String):voidAdd a path to the model.
ParameterspathId:String — The path identifier.
|
|
path:String — The path.
|
public class Main extends DocumentController
{
override protected function initPaths():void
{
ml.addPath("root","./");
ml.addPath("assets",ml.getPath("root")+"assets/");
ml.addPath("bitmaps",ml.getPath("root","assets")+"bitmaps/");
testPaths();
}
//illustrates how the "getPath" function works.
private function testPaths():void
{
trace(ml.getPath("root")); // -> ./
trace(ml.getPath("assets")); // -> ./assets/
trace(ml.getPath("bitmaps")); // -> ./assets/bitmaps/
}
}
| allowCrossScriptingDomains | () | method |
public function allowCrossScriptingDomains():voidAllows a domain for cross scripting this swf.
This is specifically for cases where a swf needs to allow an outer swf access (Security.allowDomain()).
| applyProperties | () | method |
public function applyProperties(obj:*, xml:*):voidApply a hierarchy of property values to an object. The xml should be a reference to the root node that corresponds to the object provided, it recurses down the xml in parallel with the object chain and sets property values.
Parametersobj:* — The root object.
|
|
xml:* — The root xml.
|
| attrAsBool | () | method |
public function attrAsBool(attributeID:String):BooleanA shortcut method to get an attribute as a boolean.
ParametersattributeID:String — The id of an attribute node.
|
Boolean |
| attrAsInt | () | method |
public function attrAsInt(attributeID:String):intA shortcut method to get an attribute as an integer.
ParametersattributeID:String — The id of an attribute node.
|
int |
| attrAsNumber | () | method |
public function attrAsNumber(attributeID:String):NumberA shortcut method to get an attribute as a number.
ParametersattributeID:String — The id of an attribute node.
|
Number |
| checkForXML | () | method |
protected function checkForXML():voidCheck that the model xml was set on the singleton instance before any attempts to read the xml happens.
| clearCache | () | method |
public function clearCache():voidClears the internal cache.
The internal cache caches textformats and stylesheets.
| dispose | () | method |
public function dispose():voidDispose of this model.
| doesLinkExist | () | method |
public function doesLinkExist(id:String):BooleanCheck whether or not a link is defined in the model.
Parametersid:String — The link id.
|
Boolean |
| get | () | method |
public static function get(id:String):ModelGet a model instance.
Parametersid:String — The id of the model.
|
Model |
| getAssetByLibraryName | () | method |
public function getAssetByLibraryName(libraryName:String, prependSourcePath:String = null):AssetGet an Asset instance by the library name.
ParameterslibraryName:String — The libraryName of the asset to create.
|
|
prependSourcePath:String (default = null) — The path to prepend to the source property of the asset.
|
Asset |
| getAssetGroup | () | method |
public function getAssetGroup(groupId:String):ArrayGet an array of asset objects, defined by a group node.
ParametersgroupId:String — The id of the group node.
|
Array |
| getAssetsByLibraryNames | () | method |
public function getAssetsByLibraryNames(... libraryNames):ArrayGet an array of asset objects, from the provided library names.
Parameters... libraryNames — An array of library names.
|
Array |
| getAssetsForPreload | () | method |
public function getAssetsForPreload():ArrayReturns an array of Asset instances from the assets node, that has a "preload" attribute set to true (preload='true').
ReturnsArray |
| getAttribute | () | method |
public function getAttribute(attributeID:String):StringGet the value from an attribute node.
ParametersattributeID:String — The id of an attribute node.
|
String |
| getCaptionsByGroupId | () | method |
public function getCaptionsByGroupId(groupId:String):*Returns a captioning set for flv captioning.
ParametersgroupId:String — The captioning group id.
|
* |
| getColorAs0xHexString | () | method |
public function getColorAs0xHexString(selector:String):StringGet a color in hex with 0x, (0xff0066).
Parametersselector:String — The select from the "colors" stylesheet.
|
String |
See also
| getColorAsInt | () | method |
public function getColorAsInt(selector:String):intGet's a color defined in the "colors" stylesheet. There must be a stylesheet defined with the id of "colors".
Parametersselector:String — The selector from "colors" the stylesheet.
|
int |
<stylsheets>
<stylesheet id="colors">
<![CDATA[
.pink{color:#ff0066}
]]>
</stylesheet>
</stylesheets>
var color:int=Model.gi().getColorAsInt(".pink");
| getColorAsPoundHexString | () | method |
public function getColorAsPoundHexString(selector:String):StringGet a color in hex with #, (#ff0066).
Parametersselector:String — The select from the "colors" stylesheet.
|
String |
See also
| getHTTPCallById | () | method |
public function getHTTPCallById(serviceId:String, callId:String):HTTPCallGet an HTTPCall instance by id.
ParametersserviceId:String — The service id.
|
|
callId:String — The call id.
|
HTTPCall |
| getHTTPServiceById | () | method |
public function getHTTPServiceById(id:String):HTTPServiceGet an HTTPService by id.
Parametersid:String — The service id.
|
HTTPService |
| getLink | () | method |
public function getLink(id:String):URLRequestCreates and returns a URLRequest from a link node.
Parametersid:String — The id of the link node.
|
URLRequest |
| getLinkWindow | () | method |
public function getLinkWindow(id:String):StringGet the window attribute value on a link node.
Parametersid:String — The id of the link node.
|
String |
| getPath | () | method |
public function getPath(... pathIds):StringGet a path concatenated from the given pathIds.
Parameters... pathIds — An array of pathIds whose values will be concatenated together.
|
String |
| getRemotingCallById | () | method |
public function getRemotingCallById(serviceId:String, callId:String):RemotingCallGet a remoting call by service, and call id.
ParametersserviceId:String — The id of the remoting call.
|
|
callId:String |
RemotingCall |
| getRemotingServiceById | () | method |
public function getRemotingServiceById(id:String):RemotingServiceGet a remoting service by id.
Parametersid:String — The service id.
|
RemotingService |
| getSoapServiceById | () | method |
public function getSoapServiceById(id:String):SoapServiceGet a soap service by id.
Parametersid:String — The soap service id.
|
SoapService |
| getStyleSheetById | () | method |
public function getStyleSheetById(id:String):StyleSheetGet a StyleSheet object by the node id.
There is one extra "feature" that this can do - setting the proper font names for you, based off of the "font" or "fontFamily".
If you specify a "font" style, this will look for a font defined in the model, grab it out of the library, and use font.fontName as the "fontFamily" style.
If you specify the "fontFamily" style, this will use the asset manager to try and grab your font out, and replace what you have defined for the "fontFamily" style with the proper name.
Parametersid:String — The id of the stylesheet node to grab from the model.
|
StyleSheet |
| getTextAttributeById | () | method |
public function getTextAttributeById(id:String):TextAttributesGet a text attributes.
Parametersid:String — The id of a text attribute node.
|
TextAttributes |
| getTextFormatById | () | method |
public function getTextFormatById(id:String):TextFormatGet a TextFormat object by the node id.
Supports these attributes:
id:String |
TextFormat |
| isPathDefined | () | method |
public function isPathDefined(path:String):BooleanCheck whether or not a path has been defined.
Parameterspath:String |
Boolean |
| load | () | method |
public function load(model:String, complete:Function, ioerror:Function = null, securityerror:Function = null):voidLoad an xml file to use as the model xml.
Parametersmodel:String — The model xml file name.
|
|
complete:Function — A callback function for on complete of the xml load.
|
|
ioerror:Function (default = null) — A callback function to handle ioerrors.
|
|
securityerror:Function (default = null) — A callback function to handle security errors.
|
| loadPolicyFiles | () | method |
public function loadPolicyFiles():voidLoads all the security policy files specified in the model.
| mergeStyleSheetsAs | () | method |
public function mergeStyleSheetsAs(newStyleId:String, ... styleIds):StyleSheetMerge any number of style sheets declared in the model as a new stylesheet with a unique id. The new stylesheet is returned to you, and can be accessed again through the getStyleSheetById method. You can also declare merged style sheets in the model through xml.
ParametersnewStyleId:String — The id to name the new merged stylesheet.
|
|
... styleIds — An array of style ids that are defined in the model.
|
StyleSheet |
| navigateToLink | () | method |
public function navigateToLink(id:String):voidNavigates to a link.
Parametersid:String — The link id.
|
| registerFonts | () | method |
public function registerFonts(groupId:String = null):voidRegister declared fonts from the model. If no group id is specified, all fonts declared are registered.
ParametersgroupId:String (default = null) — Optionally register fonts that were declared as part of a specific group.
|
| set | () | method |
public static function set(id:String, ml:Model):voidSet a model instance.
Parametersid:String — The model id.
|
|
ml:Model — The model instance.
|
| traceFonts | () | method |
public function traceFonts(groupId:String = null):*Traces information about fonts that will be registered when calling the registerFont method.
ParametersgroupId:String (default = null) — Optionally trace fonts that were declared as part of a specific group.
|
* |
| unset | () | method |
public static function unset(id:String):voidUnsets (deletes) a model instance.
Parametersid:String |