Link to home
Start Free TrialLog in
Avatar of cflores89
cflores89

asked on

Is it possible to search xml embedded in flex?

Is it possible to have a flex document do a query?

I have a simple project for work, where the items are loaded in a product tile window and I want it to be able to search.

The file needs to live on an network drive, and be safe contained no php etc.

Thanks,
-C
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:ns1="*">
 
<mx:XML id="product">
 
	<product><anitem>	<itemID>	1	</itemID>	<itemName>	Light (1) 	</itemName>	<type>	Skin (1000)  	</type>	<gender>	Female  	</gender>	<price>	0	</price>	<crDate>	5/3/2008 20:26	</crDate>	<isactive>	1	</isactive>	<imgURL>		</imgURL>	</anitem>
	<anitem>	<itemID>	2	</itemID>	<itemName>	Light (2) 	</itemName>	<type>	Skin (1000)  	</type>	<gender>	Male  	</gender>	<price>	0	</price>	<crDate>	5/3/2008 20:27	</crDate>	<isactive>	1	</isactive>	<imgURL>	</imgURL>	</anitem>
	<anitem>	<itemID>	3	</itemID>	<itemName>	Light Brown (3) 	</itemName>	<type>	Skin (1000)  	</type>	<gender>	Female  	</gender>	<price>	0	</price>	<crDate>	5/3/2008 20:28	</crDate>	<isactive>	1	</isactive>	<imgURL></imgURL>	</anitem>
	<anitem>	<itemID>	4	</itemID>	<itemName>	Dark Brown (4) 	</itemName>	<type>	Skin (1000)  	</type>	<gender>	Female  	</gender>	<price>	0	</price>	<crDate>	5/3/2008 20:28	</crDate>	<isactive>	1	</isactive>	<imgURL>		</imgURL>	</anitem>
	<anitem>	<itemID>	5	</itemID>	<itemName>	Tanned (5) 	</itemName>	<type>	Skin (1000)  	</type>	<gender>	Female  	</gender>	<price>	0	</price>	<crDate>	5/3/2008 20:28	</crDate>	<isactive>	1	</isactive>	<imgURL>		</imgURL>	</anitem>
	<anitem>	<itemID>	6	</itemID>	<itemName>	Light Brown (6) 	</itemName>	<type>	Skin (1000)  	</type>	<gender>	Male  	</gender>	<price>	0	</price>	<crDate>	5/3/2008 20:28	</crDate>	<isactive>	1	</isactive>	<imgURL>		</imgURL>	</anitem>
	<anitem>	<itemID>	7	</itemID>	<itemName>	Dark Brown (7) 	</itemName>	<type>	Skin (1000)  	</type>	<gender>	Male  	</gender>	<price>	0	</price>	<crDate>	5/3/2008 20:28	</crDate>	<isactive>	1	</isactive>		<imgURL>		</imgURL>	</anitem>
	<anitem>	<itemID>	8	</itemID>	<itemName>	Tanned (8) 	</itemName>	<type>	Skin (1000)  	</type>	<gender>	Male  	</gender>	<price>	0	</price>	<crDate>	5/3/2008 20:29	</crDate>	<isactive>	1	</isactive>	<imgURL>		</imgURL>	</anitem>
	<anitem>	<itemID>	100	</itemID>	<itemName>	Green Eyes (100) 	</itemName>	<type>	Eyes (1001)  	</type>	<gender>	Female  	</gender>	<price>	0	</price>	<crDate>	5/3/2008 20:29	</crDate>	<isactive>	1	</isactive>		<imgURL>		</imgURL>	</anitem>
	<anitem>	<itemID>	101	</itemID>	<itemName>	Blue Eyes (101) 	</itemName>	<type>	Eyes (1001)  	</type>	<gender>	Female  	</gender>	<price>	0	</price>	<crDate>	5/3/2008 20:29	</crDate>	<isactive>	2	</isactive>		<imgURL>		</imgURL>	</anitem>
	<anitem>	<itemID>	102	</itemID>	<itemName>	Brown Eyes (102) 	</itemName>	<type>	Eyes (1001)  	</type>	<gender>	Female  	</gender>	<price>	0	</price>	<crDate>	5/3/2008 20:29	</crDate>	<isactive>	1	</isactive>	<imgURL>		</imgURL>	</anitem>
	<anitem>	<itemID>	103	</itemID>	<itemName>	Aqua Eyes (103) 	</itemName>	<type>	Eyes (1001)  	</type>	<gender>	Female  	</gender>	<price>	0	</price>	<crDate>	5/3/2008 20:30	</crDate>	<isactive>	1	</isactive>	<imgURL>		</imgURL>	</anitem>
	<anitem>	<itemID>	104	</itemID>	<itemName>	Blue Eyes (104) 	</itemName>	<type>	Eyes (1001)  	</type>	<gender>	Male  	</gender>	<price>	0	</price>	<crDate>	5/3/2008 20:30	</crDate>	<isactive>	1	</isactive>		<imgURL>		</imgURL>	</anitem>
	<anitem>	<itemID>	105	</itemID>	<itemName>	Green Eyes (105) 	</itemName>	<type>	Eyes (1001)  	</type>	<gender>	Male  	</gender>	<price>	0	</price>	<crDate>	5/3/2008 20:30	</crDate>	<isactive>	1	</isactive>	<imgURL>		</imgURL>	</anitem>
 
	</product>																													
																												
</mx:XML>
	<mx:Panel x="379" y="10" width="635" height="445" layout="absolute">
		<mx:TileList itemRenderer="ProductTile" dataProvider="{product.anitem}" x="19" y="10" width="586" height="390" rowHeight="136" columnWidth="180">
		
		</mx:TileList>
	</mx:Panel>
	<mx:Panel x="29" y="189" width="342" height="266" layout="absolute">
		<mx:CheckBox x="196" y="194" label="YoCash Items"/>
		<mx:Text x="10" y="20" text="Name&#x9;" width="63"/>
		<mx:TextInput x="81" y="18"/>
		<mx:Text x="10" y="55" text="Max Price" width="63"/>
		<mx:TextInput x="81" y="53" width="81"/>
		<mx:Text x="10" y="85" text="Min Price" width="63"/>
		<mx:TextInput x="81" y="83" width="81"/>
		<mx:ComboBox x="10" y="161" dataProvider="{categories.category}" width="178" id = "cat"  click="traceCat()"></mx:ComboBox>
	</mx:Panel>
 
<mx:XML id = "categories">
<categories>
<category>	Swimwear (2020)  	</category>
<category>	Rugs (2008)  	</category>
<category>	Toys and Games (2035)  	</category>
<category>	Homes (2029)  	</category>
<category>	Kitchen Appliances (2022)  	</category>
<category>	Pants (100)  	</category>
<category>	Bait (2049)  	</category>
 
</categories>
</mx:XML>
 
	<mx:Script>
	private var txt:String;
	public function traceCat():void
	{
		txt =cat.selectedItem.text;
	trace(txt);
	}
	</mx:Script>
</mx:Application>
 
 
<?xml version="1.0" encoding="utf-8"?>
<mx:Tile xmlns:mx="http://www.adobe.com/2006/mxml" width="180" height="136">
	<mx:Canvas width="180" height="136">
	
	
		<mx:Image x="35.5" y="24" width="60" height="60" source="{data.imgURL}"/>
		<mx:Label x="10" y="9" width="155" text ="{data.itemName}"/>
		<mx:Label x="35.5" y="97" text = "{data.price}"/>
 
	</mx:Canvas>
	
</mx:Tile>

Open in new window

Avatar of lexxwern
lexxwern
Flag of Netherlands image

Yes, you can use XMLLists and E4X. See this: http://learn.adobe.com/wiki/display/Flex/E4X
Avatar of cflores89
cflores89

ASKER

So I would have it do my query, pass the results into an XMLLlist and then pass it into the tiles?
ASKER CERTIFIED SOLUTION
Avatar of lexxwern
lexxwern
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ok, I've been fiddling around with this and can't seem to get it to work.

I had dataprovider = "{search.anitem}" for the tile and it was blank

I then had
<mx:Script>
            <![CDATA[
 
      var filterBy:String = "type";
       var filterValue:String = "Eyes";
       var items:XMLList;
  public function searchQuery():void
  {
       items= product.anItem.(attribute(filterBy) == filterValue);
       trace("check");

  }
            ]]>
      </mx:Script>

so not sure to set it up correctly