Sorry for the delayed response, it's been a busy day.

It's been a while since I have touched Lingo, so I won't comment there, but yah it's basically a list of properties. Associative arrays can be accessed in two ways. First:

listRelationships:Object = new Object();
listRelationships["propertyName"] = "foo";
trace(listRelationships["propertyName"]);

and second:

listRelationships:Object = new Object();
listRelationships.propertyName = "foo";
trace(listRelationships.propertyName);

The two syntaxes are equivalent and interchangeable. I used the first syntax because it easily allows you to access properties by name, passed through another variable.

var itemID:String = "itemID1";
trace(listRelationships[itemID]);

You would create your full data structure, each line representing one list item and containing an array of IDs linked to the given ID. Ideally you would pull this data in from an external source, such as through XML or through LoadVars, and build this data structure dynamically. Also, this is only one way of doing it. Another way may be more appropriate for you, given your particular requirements.

var listRelationships:Object = new Object();
listRelationships["itemID1"] = ["itemID2", "itemID3"];
listRelationships["itemID2"] = ["itemID1"];
listRelationships["itemID3"] = ["itemID1", "itemID3"];
...
listRelationships["itemIDN"] = ["itemID6", "itemID7", "itemID8"];

When one of the items is selected or moused over, you call a function that you create, pass in the ID of the item in question, and use that ID to find the related IDs:

function handleSelect(itemID:String):Void
{
    var selectedItemData:Array = listRelationships[itemID];
    for (var i:Number = 0; i < selectedItemData.length; i++)
    {
        // Get each row that should also be highlighted
        trace(selectedItemData[i]);
    }
}

I hope this helps.

Nathan
http://www.nathanderksen.com


On Jan 30, 2006, at 9:26 AM, Kent Humphrey wrote:


On 30 Jan 2006, at 17:13, Nathan Derksen wrote:

Well, regardless of whether or not you use listeners, you still need to create the data relationship. I don't think encoding the relationships into 25 listeners is necessarily a good idea, either. An associative array, indexed by ID, could store the IDs of the other list items that are related, all in a single data structure. So for instance:

listRelationships["itemID1"] = ["itemID2", "itemID3"];
listRelationships["itemID2"] = ["itemID1"];
listRelationships["itemID3"] = ["itemID2"];

This allows you to store arbitrary relationships between each list item. When a list item is moused over, just grab listRelationships [itemID] and you will get a corresponding array of list items to highlight.

Nathan
http://www.nathanderksen.com

That sounds a bit more like where I'm at. Not that I've used associative arrays before, but they're basically the same as property lists in Lingo right?

In your above example, wont I still need a listRelationships ["itemID1"] = [whatever] line for each item I'm wanting to reference? Or have I totally misunderstood what's going on there?
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to