Link to home
Start Free TrialLog in
Avatar of moglie
moglie

asked on

List control to change dataprovider on a TileList

I have a list control populated via xml and when you click one of the items in the list, I'd like to change the dataprovider on a tilelist based on that selection.  The dataproviders for the tilelist would be xmllistcollections.  So I guess I'd have several XMLListCollections and then the dataProvider for the tileList would need to be dynamic?  And could the dataProvider somehow be defined in the xml for the list control?
Avatar of Fuzzy_Logic_
Fuzzy_Logic_
Flag of United Kingdom of Great Britain and Northern Ireland image

There are a few ways you could do this.

I would have a function that gets a new XMLListCollection based on a url. Then reference that xml address in the xml file that builds your main TileList.

Then in the main TileList capture the click event and point it to the function that gets a new XMlListCollection. Once the XMlListColleciton is loaded, point the dataProvider for your 'sub'TileList in the direction of your newXMLListCollection.
Avatar of moglie
moglie

ASKER

This is what I have so far.  Of course it's not fully working.

                  private function changeHandler(evt:Event):void {                        
                         categoryTile.dataProvider = evt.currentTarget.selectedItem.provider;
                   }  

and then a few xmllistcollections:

      <mx:XML id="xml1" source="gallery.xml"/>
      <mx:XMLListCollection id="xmlListCol1l" source="{xml.image}"/>  

       <mx:XML id="xml2" source="gallery.xml"/>
      <mx:XMLListCollection id="xmlListColl2" source="{xml.image}"/>

       <mx:XML id="xml3" source="gallery.xml"/>
      <mx:XMLListCollection id="xmlListColl3" source="{xml.image}"/>

and then the xml:

<root>
      <categories>
            <name>Adjusting to War Memroies</name>
            <provider>xmlListColl1</provider>
      </categories>
      <categories>
            <name>Dealing With Depression</name>
            <provider>xmlListColl2</provider>
      </categories>
      <categories>
            <name>Handling Stress</name>
            <provider>xmlListColl3</provider>
      </categories>
</root>
Avatar of moglie

ASKER

Just for testing, if I directly assign a specific dataProvider in the function, it will obviously populate the tilelist with that data.  But can I use the provider node in the list control xml to essentially assign an xmllistcollection dp?

                  private function changeHandler(evt:Event):void {
                        categoryTile.dataProvider = xmlListColl;

                   }      

This just isn't working
 
categoryTile.dataProvider = evt.currentTarget.selectedItem.provider;

Open in new window

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