views:

76

answers:

1

Here is the xml file

<glossary>
<alphabet id="A">
    <term heading= "Anchor" definition="A mechanical device that prevents a vessel from moving"/>
        <term heading= "Atlas" definition="A collection of maps in book form"/>
    </alphabet>
    <alphabet id="D">
        <term heading= "Delay" definition="Time during which some action is awaited"/>
    </alphabet>
    <alphabet id="R">
        <term heading= "Risk" definition="A source of danger; a possibility of incurring loss or misfortune"/>
        <term heading= "Rotate" definition="Turn on or around an axis or a center"/>
    </alphabet>

</glossary>

fla file:

import fl.controls.List;
import fl.events.ListEvent;
var xmlLoader:URLLoader= new URLLoader();
xmlLoader.load(new URLRequest("datalist.xml"));
xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);
var xmlData:XML= new XML();
var myArr:Array= new Array();
function xmlLoaded(e:Event):void {
    xmlData= new XML(e.target.data);
    xmlData.ignoreWhitespace = true;
    //trace(xmlData.term.length());
    ParseData(xmlData);
}
function ParseData(dispTerm:XML):void {
    var termList:XMLList = dispTerm.alphabet.term.@heading;
    //trace(termList)
    var meaningList:XMLList = dispTerm.alphabet.term.@definition;
    //trace(meaningList)
    for (var i:int = 0; i < termList.length(); i++) {
        var termElement:XML = termList[i];
        var meaningElement:XML = meaningList[i];
        mytermList.addItem({label:termList[i], data:termList[i]});
        mytermList.addEventListener(ListEvent.ITEM_CLICK, itemclicked);
        //meaningList.definition=dispTerm.alphabet.term.@definition;
        //mymeaningList.addItem({label:meaningList[i], data:meaningList[i]});
    }
}

function itemclicked(evt:ListEvent):void {
    //trace(evt.item.definition.attribute);
    /*for (var i:int = 0; i < termList.length(); i++) {
    mymeaningList.addItem({label:meaningList[i], data:meaningList[i]});
    }*/
}

In this example, heading is showing in list, i want when user click on listitem, related definition will show another list. Is it possible in this fla file? or i have to take another class file?

A: 

Yes, it is possible in one FLA file.

Just an event listener to your termList to add the meaning to your meaningList on roll over. Something like this:

termList.addEventListener(ListEvent.ITEM_ROLL_OVER, showDetails);

function showDetails(e:ListEvent):void {
    //code to add item to meaningList
}
Todd Moses