简体   繁体   English

具有扩展子列表的AS3列表

[英]AS3 List with expanding sublists

Basically I have a list of states that scrolls through, and I want a list of towns to appear next to the state once the cursor is over it. 基本上,我有一个可滚动浏览的州列表,并且我希望一旦光标移到该州上方,便会在该州旁边显示一个城镇列表。

I tried making each state name a button, and going to the Over frame and adding the town list there, but the cursor picks up the towns when they're invisble, and all the town lists appear. 我尝试将每个州的名称设置为按钮,然后转到Over框并在此处添加城镇列表,但是当光标不可见时,光标会拾取这些城镇,并且所有城镇列表都会出现。

Is there a smarter way to go about this? 有没有更聪明的方法来解决这个问题?

Since you are not showing us any code, I still can help but it will be a little harder, what you need to do is something like this: 由于您没有向我们显示任何代码,因此我仍然可以提供帮助,但是会有些困难,您需要执行以下操作:

myStateButton.addEventListener(MouseEvent.MOUSE_OVER, enableTowns);

function disableTowns($event:MouseEvent):void {
   $event.target.removeEventListener(MouseEvent.MOUSE_OUT, disableTowns);
   $event.target.addEventListener(MouseEvent.MOUSE_OVER, enableTowns);
   myTownsSubmenu.mouseEnabled = false;
}

function enableTowns($event:MouseEvent):void {
   $event.target.removeEventListener(MouseEvent.MOUSE_OVER, enableTowns);
   $event.target.addEventListener(MouseEvent.MOUSE_OUT, disableTowns);
   myTownsSubmenu.mouseEnabled = true;
}

What all this code does is first add a trigger on the button so when you move your cursor over it, this will execute the enableTowns function which is going to enable mouse focusing on the sub-buttons, when you move out this will disable the mouse focus on these buttons, it's important you nest this sprites or movieclips correctly. 这些代码的全部作用是首先在按钮上添加一个触发器,因此当您将光标移到按钮上时,它将执行enableTowns函数,该功能将使鼠标聚焦于子按钮,而当您移开时,这将禁用鼠标专注于这些按钮,正确嵌套此精灵或影片剪辑很重要。

Main Button -> Sub Buttons 主按钮->子按钮

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM