弹性下拉列表:我怎么知道列表是在上方还是下方展开?

flex dropdown: how do I know if the list expands above or below?

所以在 flex 中,当您单击下拉列表时,弹出的列表可以位于下拉选项卡下方或选项卡上方。我猜是因为如果屏幕下方没有足够的空间,它会弹出选项卡上方的列表。我怎么知道它是向上扩展还是向下扩展?作为一个附带问题,有没有办法控制列表弹出的位置,比如只在选项卡下方展开?

是的,您可以像 gdcool 在 link 中提到的那样,自己构建整个菜单。但我找到了一个更简单的解决方案并比较了 mouseY 属性:

var pointy:Number = this.contentMouseY;

var pointyDropList:Number = this.dropDown.mouseY;

所以简单地说,pointy 变量确定鼠标相对于选项卡的 Y 位置("this" 是下拉对象),pointyDropList 变量确定鼠标相对于下拉列表的 Y 位置。如果下拉列表扩展到下方,则 pointyDropList 变量将始终小于 pointy。否则,如果下拉列表扩展到 pointyDropList 之上,则它总是大于 pointy 变量。所以基本上:

if(pointyDropList > pointy)
{
    //the drop down is above the tab
}
else
{
   //the drop down is below the tab
}