home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2004 July
/
CMCD0704.ISO
/
Software
/
Demo
/
elearn
/
Geografie
/
interfata.swf
/
scripts
/
FListBoxSymbol.as
< prev
next >
Wrap
Text File
|
2004-05-12
|
5KB
|
161 lines
function FListBoxClass()
{
this.itemSymbol = "FListItemSymbol";
this.init();
this.permaScrollBar = true;
var i = 0;
while(i < this.labels.length)
{
this.addItem(this.labels[i],this.data[i]);
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);
}
}
FListBoxClass.prototype = new FScrollSelectListClass();
Object.registerClass("FListBoxSymbol",FListBoxClass);
FListBoxClass.prototype.getSelectedIndices = function()
{
var tmpArray = new Array();
for(var i in this.selected)
{
tmpArray.push(this.selected[i].sIndex);
}
return tmpArray.length <= 0 ? undefined : tmpArray;
};
FListBoxClass.prototype.getSelectedItems = function()
{
var indices = this.getSelectedIndices();
var tmpArray = new Array();
var i = 0;
while(i < indices.length)
{
tmpArray.push(this.getItemAt(indices[i]));
i++;
}
return tmpArray.length <= 0 ? undefined : tmpArray;
};
FListBoxClass.prototype.getSelectMultiple = function()
{
return this.selectMultiple;
};
FListBoxClass.prototype.getRowCount = function()
{
return this.numDisplayed;
};
FListBoxClass.prototype.setSelectedIndices = function(indexArray)
{
this.clearSelected();
var i = 0;
while(i < indexArray.length)
{
this.selectItem(indexArray[i],true);
i++;
}
this.updateControl();
};
FListBoxClass.prototype.setSelectMultiple = function(flag)
{
this.selectMultiple = flag;
};
FListBoxClass.prototype.setRowCount = function(count)
{
var hgt = count * (this.itmHgt - 2) + 2;
this.setSize(this.width,hgt);
};
FListBoxClass.prototype.setWidth = function(wdt)
{
this.setSize(wdt,this.height);
};
FListBoxClass.prototype.setSize = function(w, h)
{
if(!this.enable)
{
return undefined;
}
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);
};
FListBoxClass.prototype.removeItemAt = function(index)
{
this.selectHolder = this.getSelectedIndices();
return super.removeItemAt(index);
};
FListBoxClass.prototype.selectionHandler = function(itemNum)
{
if(this.clickFilter)
{
var index = this.topDisplayed + itemNum;
if(this.getItemAt(index) == undefined)
{
this.changeFlag = false;
return undefined;
}
this.changeFlag = true;
if(!this.selectMultiple && !Key.isDown(17) || !Key.isDown(16) && !Key.isDown(17))
{
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(16) && this.selectMultiple)
{
if(this.lastSelected == -1)
{
this.lastSelected = index;
}
var incr = this.lastSelected >= index ? -1 : 1;
this.clearSelected();
var i = this.lastSelected;
while(i != index)
{
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));
}
i += incr;
}
this.selectItem(index,true);
this.container_mc["fListItem" + (index - this.topDisplayed) + "_mc"].drawItem(this.getItemAt(index),this.isSelected(index));
}
else if(key.isDown(17))
{
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;
}
};
FListBoxClass.prototype.moveSelBy = function(itemNum)
{
super.moveSelBy(itemNum);
this.releaseHandler();
};