Flex 4.6 XML search and matching example, complete code

Source: Internet
Author: User

Synchronize to: http://www.waylau.com/flex-4-6-xml-search-sample-matches/

See figure

Initialization Interface

Enter "Settings" to search and match the page

Below is the code

<? XML version = "1.0" encoding = "UTF-8"?> <S: Application xmlns: FX = "http://ns.adobe.com/mxml/2009" xmlns: S = "Library: // ns.adobe.com/flex/spark" xmlns: MX = "Library: // ns.adobe.com/flex/mx "minwidth =" 955 "minheight =" 600 "creationcomplete =" Init (event) "> <FX: SCRIPT> <! [CDATA [import MX. events. flexevent; import MX. utils. stringutil; import spark. events. textoperationevent; Public var rawlist: xml = <apps name = "application"> <item name = "about" icon = "plugins/about_002/assets/icons/about_48.png" iconsmall = "plugins/about_002/assets/ icons/about_24.png "moduleurl =" plugins/about_002/ahout_002.swf "version =" 1.0 "date =" 2013-5-13 "author =" way "type =" plugin "Description =" about the energy management center "/> <Item name = "program management" icon = "plugins/appmanager_001/assets/icons/plugin" iconsmall = "plugins/appmanager_001/assets/icons/apps_24.png" moduleurl = "plugins/appmanager_00 /appmanager_001.swf "version =" 1.0 "date =" 2013-3-5 "author =" way "type =" plugin "resizable =" false "Description =" applies to the system, and user-defined applications for management "shortcutcreated =" true "/> <item name =" navigation Settings "icon =" plugins/navigatorsetting_001/assets/icons/gears_48.png" Iconsmall = "plugins/navigatorsetting_001/assets/icons/gears_24.png" moduleurl = "plugins/plug/ navigatorsetting_001.swf" version = "1.0" date = "2013-3-13" author = "way" type =" plugin "resizable =" false "Description =" Set navigation "/> <item name =" topic Settings "icon =" plugins/themesetting_001/assets/icons/icon_48.png "iconsmall = ""plugins/themesetting_001/assets/icons/icon_24.png" moduleurl = "plugins/themesetting _ 001/themesetting_001.swf "version =" 1.0 "date =" 2013-3-5 "author =" way "type =" plugin "resizable =" false "Description =" perform system theme and Style set "/> </apps>; [Bindable] public var rawlistshow: xml = NULL; // search for the filtered data protected function Init (Event: flexevent): void {getdata ();} protected function textinput#changehandler (event: textoperationevent): void {getdata () ;}// initialize the data private function getdata (): void {If (stringutil. trim (Tex Tinput. Text) = "") {rawlistshow = rawlist;} else {createnewxml (textinput. Text, rawlist);}/* open or close all tree projects under the specified project. If you call expandchildrenof () immediately after setting dataprovider, you may not be able to see the correct action. You should wait for the component to be verified or call the validatenow () method */tree1.validatenow (); expandtree () ;}// after searching and filtering, generate a new xmlprivate function createnewxml (searchstring: string, XML: XML): void {rawlistshow = <apps name = "app"/>; For (var I: Int = 0; I <XML. children (). length (); I ++) {var itemxml: xml = xml. child ("item") [I]; If (isinstr (searchstring, itemXml.@name.toString () {rawlistshow. appendchild (itemxml) ;}}// judge whether search_str is in the STR public function is Instr (search_str: String, STR: string): Boolean {var num: Int = Str. indexof (search_str); If (Num>-1) {return true;} else {return false ;}// expand the tree private function expandtree (): void {for each (VAR item: XML in this. tree1.dataprovider) This. tree1.expandchildrenof (item, true) ;}]> </FX: SCRIPT> <FX: declarations> <! -- This example is provided by waylau.com --> </FX: declarations> <s: textinput prompt = "enter the field to search" x = "10" Y = "10" change = "textinput#changehandler (event)" id = "textinput"/> <mx: tree id = "tree1" dataprovider = "{rawlistshow}" labelfield = "@ name" width = "200" Height = "300" x = "10" Y = "40"> </MX: tree> <s: Label text = "For more examples, see waylau.com" x = "10" Y = "360"/> </S: Application>

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.