Flex4.5 reads XML data and binds it to the ComboBox control.

Source: Internet
Author: User
<Mx: ComboBox id = "list" width = "125" Height = "26" change = "list_changehandler (Event) "chromecolor =" # c2e7fe "cornerradius =" 5 "selectedindex =" 0 "textalign =" center "/>

Import MX. collections. arraycollection; import MX. events. listevent; import MX. RPC. XML. simplexmldecoder; import spark. events. indexchangeevent;/*** send data * @ Param newdatagv source data */private function Init (): void {var xmlloader: urlloader = new urlloader (); xmlloader. addeventlistener (event. complete, xmlcomplete); xmlloader. addeventlistener (ioerrorevent. io_error, io_error); xmlloader. load (New URLRequest (xmlurl);} private function xmlcomplete (evet: Event): void {xml = New XML (evet. currenttarget. data); // var xmllist: xmllist = new xmllist (XML. record. names); var xmldoc: xmldocument = new xmldocument (XML) var decoder: simplexmldecoder = new simplexmldecoder (); var data: Object = decoder. decodexml (xmldoc); cityarr = new arraycollection (data. string. record); list. dataprovider = cityarr; List. selectedindex = 0;} private function io_error (EVT: ioerrorevent): void {trace (EVT. text. tostring ())}

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.