2012-06-29 5 views
0

사용자 이름을 가리키면 약간의 드롭 다운 영역을 보여주는 맞춤 구성 요소를 만들고 있습니다. 나는 두 개의 주를 사용하고 있는데, 내 드롭 다운 상자를 위아래로 움직입니다.마우스 위로 맞춤 드롭 다운

내 문제는 내가 사용자 이름을 남긴 후에 구성 요소 레벨 Group을 떠날 것이라고 생각합니다. 그런 다음 두 번째 레벨 그룹 (내 드롭 다운)이 사라집니다.

내 마우스 오버 기능의 callLater에있는 구성 요소 레벨 Group에 이벤트 처리기를 다시 연결했지만 작동하지 않았습니다.

<?xml version="1.0" encoding="utf-8"?> 
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009" 
     xmlns:s="library://ns.adobe.com/flex/spark" 
     xmlns:mx="library://ns.adobe.com/flex/mx" 
     mouseOver="groupLogIn_mouseOverHandler(event)" 
     mouseOut="groupLogIn_mouseOutHandler(event)" 
     > 
    <fx:Declarations> 
     <!-- Place non-visual elements (e.g., services, value objects) here --> 
    </fx:Declarations> 

    <fx:Script> 
     <![CDATA[ 
      import spark.skins.SparkSkin; 
      protected function groupLogIn_mouseOverHandler(event:MouseEvent):void 
      { 

       this.currentState = "hover"; 
      } 

      protected function groupLogIn_mouseOutHandler(event:MouseEvent):void 
      { 

       this.currentState = "up" 
      } 
     ]]> 
    </fx:Script> 

    <s:states> 
     <s:State name="up"/> 
     <s:State name="hover"/> 
    </s:states> 

    <s:Label id="lblUsername" color="0xffffff" fontSize="14" right="18" top="5"/> 

    <s:Group includeIn="hover" width="160" height="110" top="20" right="0" > 
     <s:Rect top="0" right="0" bottom="0" left="0"> 
      <s:fill> 
       <s:SolidColor color="0x1a1a1a"/> 
      </s:fill> 
     </s:Rect> 
    </s:Group> 
</s:Group> 

답변

1

마우스 이벤트에는 "hitzone"이 필요합니다. 현재 구성 요소의 일부가 완전히 투명합니다. 마우스가 투명한 영역 위로 이동하면 MOUSE_OUT 이벤트가 트리거됩니다. (내가 '투명'이라고 말할 때 μi는 실제로 거기에 아무 것도 없다는 것을 의미합니다).

다행히도 쉽게 수정할 수 있습니다. 다른 구성 요소 아래의 전체 영역을 덮는 Rect를 추가하고 alpha0으로 설정하면됩니다. 이렇게하면 Rect가 사용자에게 보이지 않게되지만 마우스 이벤트에 계속 반응 할 수 있습니다.

<s:Rect id="hitzone" top="0" right="0" bottom="0" left="0"> 
    <s:fill> 
     <s:SolidColor alpha="0" /> 
    </s:fill> 
</s:Rect> 

<s:Label id="lblUsername" /> 

... 
관련 문제