Dynamic Context Menu from XML


I’m trying to make a Context menu with content (labels/links/separators) loaded from an XML file… Here’s what I have:

import flash.events.Event;
import flash.net.URLRequest;
import flash.ui.ContextMenu;
import flash.ui.ContextMenuItem;
import flash.ui.ContextMenuBuiltInItems;
import flash.events.ContextMenuEvent;

function onContextXMLLoad(event:Event):void {
	var contextXML:XML = new XML(event.target.data);
	contextXML.ignoreWhitespace = true;

	var contMenu:ContextMenu = new ContextMenu();
	this.contextMenu = contMenu;

	for (var i:int = 0; i<contextXML.item.length(); i++) {
		var lab:String = contextXML.item*.label.text();
		var url:String = contextXML.item*.url.text();
		var contMenuItem:ContextMenuItem = new ContextMenuItem(lab);
		contMenuItem.separatorBefore = true;
		if (url != "nolink") {
			contMenuItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, onContClick, false, 0, true);

var contextXMLLoader:URLLoader = new URLLoader();
contextXMLLoader.addEventListener(Event.COMPLETE, onContextXMLLoad, false, 0, true);
contextXMLLoader.load(new URLRequest("context.xml"));

function onContClick(event:ContextMenuEvent) {
	//navigateToURL(new URLRequest(event.target.link));

Everything works fine except one problem - How can I pass the url variable to the “onContClick” function? I tried many different methods but with no result :frowning:

thnx for any help,
Philip Seyfi, divita.eu