i want a context menu that can be used with multiple textfield instances. how do u pass the textfield instance with the selection of the context menu
code so far:
//format textfield selection with bold/italics
var textfield_cm:ContextMenu = new ContextMenu();
textfield_cm.customItems.push(new ContextMenuItem(“Bold”, applyFormat));
textfield_cm.customItems.push(new ContextMenuItem(“Italic”, applyFormat));
function applyFormat(obj, menuItem) {
var startIndex:Number = Selection.getBeginIndex();
var endIndex:Number = Selection.getEndIndex();
var my_fmt:TextFormat = ttlTxt.getTextFormat(startIndex);
switch (menuItem.caption) {
case ‘Bold’ :
// toggle the bold property.
my_fmt.bold = !my_fmt.bold;
break;
case ‘Italic’ :
my_fmt.italic = !my_fmt.italic;
break;
}
ttlTxt.setTextFormat(startIndex, endIndex, my_fmt);
}
ttlTxt.menu = textfield_cm;
i also want to apply menu to
subTxt.menu = textfield_cm;
descTxt.menu = textfield_cm;
but ttlTxt is hardcoded in function :puzzle:
thanks…