Hi there
I have two listbox comps namely lb1 and lb2. I was able to load data into the first listbox and have the change event handler on it. On change in the listbox1, i want to load all the features for the selected item in lb1 into lb 2. here is my code..
------------------------
import fl.data.DataProvider;
var alld:XML;
var plist:XML;
var flist:XML;
initApp();
stop();
function initApp():void {
alld = <allitems>
<items>
<item>
<name>Kendle DX</name>
<category>Digital Reader</category>
<features>
<feature>Improved Contrast</feature>
<feature>Diagonal E-ink Screen</feature>
<feature>Zero Glare</feature>
<feature>Free 3G Wireless</feature>
<feature>Lasting Battery Life</feature>
</features>
</item>
<item>
<name>Logitech Squeezebox</name>
<category>Radio Music Player</category>
<features>
<feature>Listen to Infinite Music</feature>
<feature>Connects to All Internet Radio Stations</feature>
<feature>iTune Collections</feature>
<feature>High Quality</feature>
<feature>Facebook Connection</feature>
</features>
</item>
<item>
<name>HDR Photography Secrets</name>
<category>Photography</category>
<features>
<feature>150 Full Color Photos</feature>
<feature>200 Techniques</feature>
<feature>Inspirations Tips</feature>
<feature>Photomatix Tricks</feature>
<feature>Photoshop Tricks</feature>
</features>
</item>
</items>
</allitems>;
plist=new XML(alld.items);
lb1.dataProvider=new DataProvider(plist);
lb1.labelFunction=getName;
lb1.addEventListener(Event.CHANGE, changeHandler);
lb2.labelFunction = getFeature;
function getName(item:Object):String {
return item.name;
}
function getFeature(item:Object):String{
return item.feature;
}
function changeHandler(e:Event):void{
fea(e.currentTarget.selectedIndex);
}
function fea(itemIndex:int):void{
flist = new XML(alld..item[itemIndex].features);
lb2.dataProvider = new DataProvider(flist);
}
}
---------------------------------
somewhere something wrong. i don't know where.
Appreciate your time and help.
Thank you
Krish