Random techie babbling...

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 :


<?xml version="1.0" encoding="UTF-8"?>
<site title="Gaia Framework Site: %PAGE%" menu="false">
    <page id="index" src="index.swf" 
	        <page id="nav" src="nav.swf" depth="top">
	            <page id="home" title="Home" src="home.swf" menu="true" />

…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 :)

If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.


Got something to say? Feel free, I want to hear from you! Leave a Comment

  1. marco says:

    Thanks!! very usefull to me, Really! :)

  2. Leo says:

    This is great! and very useful indeed Thank you! I noticed you were using amfphp and wondered how did you worked around integrating it into gaia, specially in terms of preloading. Did you build a custom asset manager?

Trackbacks for this post

  1. [AS3] GAIA Framework, 自己整 custom attribute for site.xml ,這世界突然美好了。 | CODE@蝴蝶。夢

Leave a Comment

Let us know your thoughts on this post but remember to place nicely folks!