tags:

views:

100

answers:

1
<root>
<module label="Executive Library" >
         <node label="Document one"  link="http://www.google.com" />
         <node label="Document Two"  link="http://www.google.com" />
         <node label="Document Three"  link="http://www.google.com"/&gt;
       </module>

I have a page which displays these items, when i select the document One i need the link associated to be clicked. How can i achieve this programatically.

+2  A: 

It sort of depends on which set of controls you're using, but most likely you're looking for something like "event.item.@link", where the "@" signifies "attribute" -- for example:

<mx:Script>
    <![CDATA[

     import mx.events.MenuEvent;

     private function onMenuItemClick(event:MenuEvent):void
     {
      trace(event.item.@link);  
     }

    ]]>
</mx:Script>

<mx:PopUpMenuButton itemClick="onMenuItemClick(event)" labelField="@label">
    <mx:dataProvider>
     <mx:XML xmlns="">
      <module label="Executive Library" >
       <node label="Document one" link="http://www.google.com" />
       <node label="Document Two" link="http://www.google.com" />
       <node label="Document Three" link="http://www.google.com"/&gt;
      </module>
     </mx:XML>
    </mx:dataProvider>
</mx:PopUpMenuButton>

Here, I'm just using your XML (minus the root node) to populate a PopUpMenuButton's dataProvider, and capturing the itemClick event that way. Hopefully that's what you're doing as well -- post back and let me know if you have any issues.

Christian Nunciato
Thanks for the Help, private function itemClick1(event:ListEvent):void { Alert.show(event.item.@cd_link.toString); }Why this throws an error and i am using TREE component.
What's the specific error? From that code snip, one thing I see is that you should be using "toString()", not just "toString".
Christian Nunciato