Gaia : Accessing custom page attributes from site.xml
More a mental note for myself than anything else, but it’s just taken me an hour of Googling to find this simple solution.
Problem : You want to add & access custom attributes to a page node in the site.xml of a Gaia Flash site.
Solution :
[Site.xml]
<?xml version="1.0" encoding="UTF-8"?> <site title="Gaia Framework Site: %PAGE%" menu="false"> <page id="index" src="index.swf" remotingGateway="http://www.foo.com/services/amfphp" <page id="nav" src="nav.swf" depth="top"> <page id="home" title="Home" src="home.swf" menu="true" /> </page> </page> </site>
…note the custom ‘remotingGateway’ attribute on the index node. Adding a custom property is as simple as adding it as an attribute to the node. But how to read it?
Well, Gaia pages have a property called ‘node’ that contains the xml node for that page, so to access a property you can simply use AS3’s lovely XML functionality to do…
[AS Code]
//get gateway url from index page attributes gatewayUrl = Gaia.api.getPage(Pages.INDEX).node.@remotingGateway; //auto connect connect( gatewayUrl );
As always, simple when you know how


Recent Comments