PDA

View Full Version : Setting attributes with XML



Garfty
October 16th, 2008, 12:03 PM
Hello all, looking at setting a context menu with an external config.xml file, however I would also like to set the true and false attributes with this.

at the moment I have a simple node with;


<item_1>

<text><![CDATA[home]]></text>
<line>true</line>
<status>false</status>

</item_1>

and then I have my .as file with the connection to the doc and;


_menuLinkOne = new ContextMenuItem(_menuItem.item_1.text , _menuItem.item_1.line , _menuItem.item_1.status);
//_menuLinkOne.addEventListener(ContextMenuEvent.MEN U_ITEM_SELECT, CMHome, false, 0, true);
myContextMenu.customItems.push(_menuLinkOne);

but for some reason the true and false attributes do not seem to be set, can anyone shed any light on this??

Thank you!!

wvxvw
October 16th, 2008, 01:51 PM
It would be easier if you pass 1 for true and 0 for false, you could do just
Boolean(int(item_1.status.text())); But if you want it this way, you'd do it like this:

var b:Boolean = String(item_1.status.text()) == "true" ? true : false;

Garfty
October 17th, 2008, 08:05 AM
Thanks I will try this, maybe i should of named the post 'Using XML to set Boolean values'

I will try this and let you know how i get on