rendered paste body***********************************************************
var showItem = true; // Change this to false to remove
var my_cm:ContextMenu = new ContextMenu(menuHandler);
my_cm.customItems.push(new ContextMenuItem("Hello", itemHandler));
function menuHandler(obj, menuObj) {
if (showItem == false) {
menuObj.customItems[0].enabled = false;
} else {
menuObj.customItems[0].enabled = true;
}
}
function itemHandler(obj, item) {
//...put code here...
trace("selected!");
}
this.menu = my_cm;
*********************************************************
I dont know where to place this line of code to get menu where i right click on a name in my listbox in the flash chat.
#initclip 3
/*
FCFListBoxClass
EXTENDS FSelectableListClass
IMPLEMENTS FCFListItemClass
This class is the manager of the items within it.
*/
function FCFListBoxClass()
{
this.itemSymbol = "FCFListItemSymbol";
this.init();
// Test any params for undefined; if so, set defaults
this.permaScrollBar = true;
for (var i=0; i<this.labels.length; i++) {
this.addItem(this.labels[i], this.data[i]);
}
this.boundingBox_mc.gotoAndStop(1);
this.width = this._width;
this.height = this._height;
this._yscale = this._xscale = 100;
this.setSize(this.width, this.height);
if (this.changeHandler.length>0) {
this.setChangeHandler(this.changeHandler);
}
}
FCFListBoxClass.prototype = new FCFScrollSelectListClass();
Object.registerClass("FCFListBoxSymbol", FCFListBoxClass);
// ::: PUBLIC METHODS
FCFListBoxClass.prototype.getSelectedIndices = function()
{
var tmpArray = new Array();
for (var i in this.selected) {
tmpArray.push(this.selected[i].sIndex);
}
return (tmpArray.length>0) ? tmpArray : undefined;
}
FCFListBoxClass.prototype.getSelectedItems = function()
{
var indices = this.getSelectedIndices();
var tmpArray= new Array();
for (var i=0; i<indices.length; i++) {
tmpArray.push(this.getItemAt(indices[i]));
}
return (tmpArray.length>0) ? tmpArray : undefined;
}
FCFListBoxClass.prototype.getSelectMultiple = function()
{
return this.selectMultiple;
}
FCFListBoxClass.prototype.getRowCount = function()
{
return this.numDisplayed;
}
FCFListBoxClass.prototype.setSelectedIndices = function(indexArray)
{
this.clearSelected();
for (var i=0; i<indexArray.length; i++) {
this.selectItem(indexArray[i], true);
}
this.updateControl();
}
FCFListBoxClass.prototype.setSelectMultiple = function(flag)
{
this.selectMultiple = flag;
}
FCFListBoxClass.prototype.setRowCount = function(count)
{
var hgt = count *(this.itmHgt-2) + 2;
this.setSize(this.width, hgt);
}
FCFListBoxClass.prototype.setWidth = function(wdt)
{
this.setSize(wdt, this.height);
}
FCFListBoxClass.prototype.setSize = function(w,h)
{
if (!this.enable) {
return;
}
w = Math.max(w, 20);
h = Math.max(h, 40);
this.container_mc.removeMovieClip();
this.container_mc = this.createEmptyMovieClip("container", 3);
this.measureItmHgt();
this.numDisplayed = Math.floor(h / (this.itmHgt-2));
this.height = this.numDisplayed * (this.itmHgt-2) + 2;
super.setSize(w, this.height);
}
FCFListBoxClass.prototype.removeItemAt = function(index)
{
this.selectHolder = this.getSelectedIndices();
return super.removeItemAt(index);
}
// ::: PRIVATE METHODS
FCFListBoxClass.prototype.selectionHandler = function(itemNum)
{
if (this.clickFilter) {
var index = this.topDisplayed + itemNum;
if (this.getItemAt(index)==undefined) {
this.changeFlag=false;
return;
} else {
this.changeFlag = true;
}
if ( ( !this.selectMultiple && !Key.isDown(Key.CONTROL) ) || ( !Key.isDown(Key.SHIFT) && !Key.isDown(Key.CONTROL) ) ) {
//Clear all other selections, this is a single click
this.clearSelected();
this.selectItem(index, true);
this.lastSelected = index;
this.container_mc["fListItem" + itemNum + "_mc"].drawItem(this.getItemAt(index), this.isSelected(index));
}
else if ( Key.isDown(Key.SHIFT) && this.selectMultiple) {
if (this.lastSelected==-1) {
this.lastSelected=index;
}
var incr = (this.lastSelected<index) ? 1 : -1;
this.clearSelected();
for (var i=this.lastSelected; i!=index; i+=incr) {
this.selectItem(i, true);
if (i>=this.topDisplayed && i<this.topDisplayed+this.numDisplayed) {
this.container_mc["fListItem" + (i-this.topDisplayed) + "_mc"].drawItem(this.getItemAt(i), this.isSelected(i));
}
}
this.selectItem(index, true);
this.container_mc["fListItem" + (index-this.topDisplayed) + "_mc"].drawItem(this.getItemAt(index), this.isSelected(index));
}
else if (key.isDown(Key.CONTROL)) {
var selectedFlag = this.isSelected(index);
if (!this.selectMultiple) {
this.clearSelected();
}
if (!(!this.selectMultiple && selectedFlag)) {
this.selectItem(index, !selectedFlag);
this.container_mc["fListItem" + itemNum + "_mc"].drawItem(this.getItemAt(this.topDisplayed + itemNum), this.isSelected(this.topDisplayed+itemNum));
}
this.lastSelected=index;
}
} else {
this.clickFilter = true;
}
}
FCFListBoxClass.prototype.moveSelBy = function(itemNum)
{
super.moveSelBy(itemNum);
this.releaseHandler();
}
#endinitclip
var frogStyle = new FStyleFormat();
frogStyle.textColor = "0x666666";
frogStyle.textSelected = "0x333333";
frogStyle.textDisabled = "0x333333";
frogStyle.selection = "0xbefdff";
frogStyle.selectionUnfocused = "0xd8feff";
frogStyle.backgroundDisabled = "0xffffff";
frogStyle.addListener(this);
this.deadPreview._visible = false;