Simple Example of loading treemenu from XML

Source: Internet
Author: User

Treefromxml. mxml

<? XML version = "1.0" encoding = "UTF-8"?>
<Mx: Application xmlns: MX = "http://www.adobe.com/2006/mxml"
Fontfamily = "simsun" fontsize = "12"
Layout = "absolute" creationcomplete = "menu. Send ();" width = "242" Height = "442">
<Mx: SCRIPT>
<! [CDATA [
Import MX. Collections. arraycollection;
Import MX. rpc. Events. resultevent;
[Bindable]
Private var menus: XML;
Private function loadmenu (Event: resultevent): void {
Menus = XML (event. Result );
VaR results: xmllist = menus. node;
Tree. dataprovider = results;
}
]>
</MX: SCRIPT>
<Mx: httpservice url = "treemenus. xml" id = "menu" useproxy = "false"
Showbusycursor = "true" result = "loadmenu (event)" resultformat = "XML"/>

<Mx: Tree id = "Tree" x = "10" Y = "35" width = "218" Height = "397" labelfield = "@ label"/>
<Mx: Label x = "10" Y = "10" text = "Tree nodes from XML file"/>
</MX: Application>

Treemenus. xml

<? XML version = "1.0" encoding = "UTF-8"?>
<Menus>
<Node label = "mail">
<Node label = "inbox"/>
<Node label = "personal folder">
<Node label = "Demo"/>
<Node label = "personal"/>
<Node label = "saved mail"/>
<Node label = "bar"/>
</Node>
<Node label = "calendar"/>
<Node label = "sent"/>
<Node label = "trash"/>
</Node>
</Menus>

////////////////////////////////
Summary
1. Load the XML with <mx: httpserviec>, trigger the result event when the load is complete, and bind tree. dataprovider
2. You can use urlloader for dynamic loading in.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.