📄 scrollselectlist.as
字号:
if (!multipleSelection || wasKeySelected)
{
this.clearSelected(transition);
} // end if
if (!(!multipleSelection && _loc7))
{
this.selectItem(_loc3, !_loc7);
var _loc9 = !_loc7 ? ("selected") : ("normal");
_loc5.drawRow(_loc5.item, _loc9, transition);
} // end if
lastSelected = _loc3;
} // end else if
if (wasKeySelected)
{
this.dispatchEvent({type: "change"});
} // end if
delete this.wasKeySelected;
} // End of the function
function dragScroll(Void)
{
clearInterval(dragScrolling);
if (_ymouse < 0)
{
this.setVPosition(__vPosition - 1);
this.selectRow(0, false);
var _loc2 = Math.min(-_ymouse - 30, 0);
scrollInterval = 5.930000E-001 * _loc2 * _loc2 + 1 + minScrollInterval;
dragScrolling = setInterval(this, "dragScroll", scrollInterval);
this.dispatchEvent({type: "scroll", direction: "vertical", position: __vPosition});
}
else if (_ymouse > __height)
{
var _loc3 = __vPosition;
this.setVPosition(__vPosition + 1);
if (_loc3 != __vPosition)
{
this.selectRow(__rowCount - 1 - roundUp, false);
} // end if
_loc2 = Math.min(_ymouse - __height - 30, 0);
scrollInterval = 5.930000E-001 * _loc2 * _loc2 + 1 + minScrollInterval;
dragScrolling = setInterval(this, "dragScroll", scrollInterval);
this.dispatchEvent({type: "scroll", direction: "vertical", position: __vPosition});
}
else
{
dragScrolling = setInterval(this, "dragScroll", 15);
} // end else if
updateAfterEvent();
} // End of the function
function __onMouseUp(Void)
{
clearInterval(dragScrolling);
delete this.dragScrolling;
delete this.dragScrolling;
delete this.isPressed;
delete this.onMouseUp;
if (!selectable)
{
return;
} // end if
if (changeFlag)
{
this.dispatchEvent({type: "change"});
} // end if
delete this.changeFlag;
} // End of the function
function moveSelBy(incr)
{
if (!selectable)
{
this.setVPosition(__vPosition + incr);
return;
} // end if
var _loc3 = this.getSelectedIndex();
if (_loc3 == undefined)
{
_loc3 = -1;
} // end if
var _loc2 = _loc3 + incr;
_loc2 = Math.max(0, _loc2);
_loc2 = Math.min(this.getLength() - 1, _loc2);
if (_loc2 == _loc3)
{
return;
} // end if
if (_loc3 < __vPosition || _loc3 >= __vPosition + __rowCount)
{
this.setVPosition(_loc3);
} // end if
if (_loc2 >= __vPosition + __rowCount - roundUp || _loc2 < __vPosition)
{
this.setVPosition(__vPosition + incr);
} // end if
wasKeySelected = true;
this.selectRow(_loc2 - __vPosition, false);
} // End of the function
function keyDown(e)
{
if (selectable)
{
if (this.findInputText())
{
return;
} // end if
} // end if
if (e.code == 40)
{
this.moveSelBy(1);
}
else if (e.code == 38)
{
this.moveSelBy(-1);
}
else if (e.code == 34)
{
if (selectable)
{
var _loc3 = this.getSelectedIndex();
if (_loc3 == undefined)
{
_loc3 = 0;
} // end if
this.setVPosition(_loc3);
} // end if
this.moveSelBy(__rowCount - 1 - roundUp);
}
else if (e.code == 33)
{
if (selectable)
{
_loc3 = this.getSelectedIndex();
if (_loc3 == undefined)
{
_loc3 = 0;
} // end if
this.setVPosition(_loc3);
} // end if
this.moveSelBy(1 - __rowCount + roundUp);
}
else if (e.code == 36)
{
this.moveSelBy(-__dataProvider.length);
}
else if (e.code == 35)
{
this.moveSelBy(__dataProvider.length);
} // end else if
} // End of the function
function findInputText(Void)
{
var _loc2 = Key.getAscii();
if (_loc2 >= 33 && _loc2 <= 126)
{
this.findString(String.fromCharCode(_loc2));
return (true);
} // end if
} // End of the function
function findString(str)
{
if (__dataProvider.length == 0)
{
return;
} // end if
var _loc4 = this.getSelectedIndex();
var _loc6 = 0;
for (var _loc3 = _loc4 + 1; _loc3 != _loc4; ++_loc3)
{
var _loc2 = __dataProvider.getItemAt(_loc3);
if (_loc2 instanceof XMLNode)
{
_loc2 = _loc2.attributes[__labelField];
}
else if (typeof(_loc2) != "string")
{
_loc2 = String(_loc2[__labelField]);
} // end else if
_loc2 = _loc2.substring(0, str.length);
if (str == _loc2 || str.toUpperCase() == _loc2.toUpperCase())
{
_loc6 = _loc3 - _loc4;
break;
} // end if
if (_loc3 >= this.getLength() - 1)
{
_loc3 = -1;
} // end if
} // end of for
if (_loc6 != 0)
{
this.moveSelBy(_loc6);
} // end if
} // End of the function
function onRowPress(rowIndex)
{
if (!enabled)
{
return;
} // end if
isPressed = true;
dragScrolling = setInterval(this, "dragScroll", 15);
onMouseUp = __onMouseUp;
if (!selectable)
{
return;
} // end if
this.selectRow(rowIndex);
} // End of the function
function onRowRelease(rowIndex)
{
} // End of the function
function onRowRollOver(rowIndex)
{
if (!enabled)
{
return;
} // end if
var _loc2 = rows[rowIndex].item;
if (this.getStyle("useRollOver") && _loc2 != undefined)
{
rows[rowIndex].drawRow(_loc2, "highlighted", false);
} // end if
this.dispatchEvent({type: "itemRollOver", index: rowIndex + __vPosition});
} // End of the function
function onRowRollOut(rowIndex)
{
if (!enabled)
{
return;
} // end if
if (this.getStyle("useRollOver"))
{
rows[rowIndex].drawRow(rows[rowIndex].item, this.getStateAt(rowIndex + __vPosition), false);
} // end if
this.dispatchEvent({type: "itemRollOut", index: rowIndex + __vPosition});
} // End of the function
function onRowDragOver(rowIndex)
{
if (!enabled || isPressed != true || !selectable)
{
return;
} // end if
if (dropEnabled)
{
}
else if (dragScrolling)
{
this.selectRow(rowIndex, false);
}
else
{
onMouseUp = __onMouseUp;
this.onRowPress(rowIndex);
} // end else if
} // End of the function
function onRowDragOut(rowIndex)
{
if (!enabled)
{
return;
} // end if
if (dragEnabled)
{
}
else
{
this.onRowRollOut(rowIndex);
} // end else if
} // End of the function
function init(Void)
{
super.init();
tabEnabled = true;
tabChildren = false;
if (__dataProvider == undefined)
{
__dataProvider = new Array();
__dataProvider.addEventListener("modelChanged", this);
} // end if
baseRowZ = topRowZ = 10;
} // End of the function
function createChildren(Void)
{
super.createChildren();
listContent = this.createEmptyMovieClip("content_mc", CONTENTDEPTH);
invLayoutContent = true;
this.invalidate();
} // End of the function
function draw(Void)
{
if (invRowHeight)
{
delete this.invRowHeight;
__rowCount = 0;
listContent.removeMovieClip();
listContent = this.createEmptyMovieClip("content_mc", CONTENTDEPTH);
} // end if
if (invUpdateControl)
{
this.updateControl();
} // end if
border_mc.draw();
} // End of the function
function invalidateStyle(propName)
{
if (isRowStyle[propName])
{
invUpdateControl = true;
this.invalidate();
}
else
{
for (var _loc3 = 0; _loc3 < __rowCount; ++_loc3)
{
rows[_loc3].invalidateStyle(propName);
} // end of for
} // end else if
super.invalidateStyle(propName);
} // End of the function
static var mixIt1 = mx.controls.listclasses.DataSelector.Initialize(mx.controls.listclasses.ScrollSelectList);
static var mixIt2 = mx.controls.listclasses.DataProvider.Initialize(Array);
var CONTENTDEPTH = 100;
var __hPosition = 0;
var __rowRenderer = "SelectableRow";
var __rowHeight = 22;
var __rowCount = 0;
var __labelField = "label";
var minScrollInterval = 30;
var dropEnabled = false;
var dragEnabled = false;
var className = "ScrollSelectList";
var isRowStyle = {styleName: true, backgroundColor: true, selectionColor: true, rollOverColor: true, selectionDisabledColor: true, backgroundDisabledColor: true, textColor: true, textSelectedColor: true, textRollOverColor: true, textDisabledColor: true, alternatingRowColors: true, defaultIcon: true};
var roundUp = 0;
var selectable = true;
var multipleSelection = false;
} // End of Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -