2012-02-07 7 views
0

나는 그리퍼가있는 창 피부를 가지고 있습니다. 그리퍼는 리스너 mousedown 및 mouseup으로 창 크기를 조정하는 데 사용됩니다.창 크기 조정

내 문제는 내가 창 크기를 조정할 때 마우스를 누르면 멈추고 창에서 아무 곳이나 클릭하면 창 크기가 조정되고 이유를 모르겠습니다.

내 코드의 아래 부분 :

protected function btResize_mouseDownHandler(event:MouseEvent):void 
     { 
      stage.addEventListener(MouseEvent.MOUSE_UP, btResize_mouseUpHandler); 
      stage.nativeWindow.startResize(); 
     } 

     protected function btResize_mouseOutHandler(event:MouseEvent):void 
     { 
      stage.removeEventListener(MouseEvent.MOUSE_OUT, btResize_mouseOutHandler);     
     } 


     protected function btResize_mouseUpHandler(event:MouseEvent):void 
     { 
      stage.removeEventListener(MouseEvent.MOUSE_UP, btResize_mouseUpHandler); 



     } 

<s:Button height="15" id="btResize" width="15" 
      bottom="0" right="0" 
      skinClass="spark.skins.spark.windowChrome.GripperSkin" 
      mouseDown="btResize_mouseDownHandler(event)" 
      mouseUp="btResize_mouseUpHandler(event)" 
      buttonMode="true"/> 

그래서, 내가 감사, 당신의 도움이.

감사

시 : 전체 코드

<s:SparkSkin xmlns:fx="http://ns.adobe.com/mxml/2009" 
     xmlns:s="library://ns.adobe.com/flex/spark" 
     xmlns:fb="http://ns.adobe.com/flashbuilder/2009" 
     xmlns:Layout="skin.Layout.*" 
     alpha.disabledGroup="0.5" 
     creationComplete="sparkskin1_creationCompleteHandler(event)"> 

<fx:Metadata> 
    [HostComponent("fr.inter.ui.windowSkin.wCustomWindow")] 
</fx:Metadata> 


<fx:Script> 
    <![CDATA[ 
     import mx.events.FlexEvent; 
     protected function btResize_mouseDownHandler(event:MouseEvent):void 
     { 
      btResize.addEventListener(MouseEvent.MOUSE_UP, btResize_mouseUpHandler); 
      stage.nativeWindow.startResize(); 
     } 

     protected function btResize_mouseOutHandler(event:MouseEvent):void 
     { 
      btResize.removeEventListener(MouseEvent.MOUSE_OUT, btResize_mouseOutHandler);    
     } 


     protected function btResize_mouseUpHandler(event:MouseEvent):void 
     { 
      btResize.removeEventListener(MouseEvent.MOUSE_UP, btResize_mouseUpHandler); 



     } 

     protected function sparkskin1_creationCompleteHandler(event:FlexEvent):void 
     { 

      if (NativeApplication.supportsDockIcon) 
      { 
       this.currentState = "supportsDockIcon";//mac 
      } 
      else 
      { 
       this.currentState = "supportsSystemTray"; 
      } 
     } 


    ]]> 
</fx:Script> 


<s:states> 
    <s:State name="disabledAndInactive" stateGroups="disabledGroup, inactiveGroup" /> 
    <s:State name="maximizedGroup"/> 
    <s:State name="normal" /> 
    <s:State name="disabled" stateGroups="disabledGroup" /> 
    <s:State name="normalAndInactive" stateGroups="inactiveGroup" /> 
    <s:State name="supportsDockIcon" /> 
    <s:State name="supportsSystemTray"/> 
</s:states> 

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

<s:Group bottom="0" left="0" right="0" 
     top="0" 
     > 
    <!--Fond de la fenetre--> 
    <s:Rect bottom="0" left="0" right="0" 
      top="0" 
      radiusX="8" radiusY="8" > 
     <s:fill> 
      <s:SolidColor color="#656565" alpha=".7" /> 
     </s:fill> 
     <s:stroke> 
      <s:SolidColorStroke color="#666666" /> 
     </s:stroke> 
    </s:Rect> 

    <s:Group height="38" id="moveArea" 
      left="0" right="0" > 

     <!--Barre bleu avec filet--> 
     <s:Rect height="25" left="10" right="10" top="10"> 
      <s:fill> 
       <s:SolidColor color="#055a90" /> 
      </s:fill> 
      <s:stroke> 
       <s:SolidColorStroke color="#666666" /> 
      </s:stroke> 
     </s:Rect> 


     <s:BitmapImage id="icon" 
         left.supportsSystemTray="5" right.supportsDockIcon="5" 
         verticalCenter="0" /> 

     <s:Label id="titleDisplay" 
       styleName="swindowTitle" 
       left.supportsSystemTray="60" left.supportsDockIcon="{this.width/2}" 
       top="18" verticalAlign="middle" horizontalCenter="0" 
       /> 

     <!--Zone de bouton--> 

     <s:HGroup right.supportsSystemTray="12" left.supportsDockIcon="12" verticalCenter="0"> 

      <s:Button id="btMinimize" buttonMode="true" 
         skinClass.supportsSystemTray="skin.components.MinimizeButtonSkin" 
         skinClass.supportsDockIcon="skin.components.MinimizeButtonSkinM" 
         verticalCenter="0"/> 

      <s:Button id="btMaximize" buttonMode="true" 
         skinClass.supportsSystemTray="skin.components.MaximizeButtonSkin" 
         skinClass.supportsDockIcon="skin.components.MaximizeButtonSkinM" 
         verticalCenter="0"/> 

      <s:Button id="closeButton" buttonMode="true" 
         skinClass.supportsSystemTray="skin.components.CloseButtonSkin" 
         skinClass.supportsDockIcon="skin.components.CloseButtonSkinM" 
         verticalCenter="0"/> 

     </s:HGroup> 

    </s:Group> 

    <!--Fond de la zone principale--> 

    <s:Rect id="background" left="10" top="35" right="10" bottom="10"> 
     <s:fill> 
      <s:LinearGradient rotation="-90"> 
       <s:GradientEntry color="#edf0f7"/> 
       <s:GradientEntry color="#fcfbfb" /> 
      </s:LinearGradient> 
     </s:fill> 
     <s:stroke> 
      <s:SolidColorStroke color="#666666" /> 
     </s:stroke> 
    </s:Rect> 

    <!--Zone dans laquelle les elements vont se positionner--> 


    <s:Group id="contentGroup" left="15" right="15" top="43" bottom="15" minWidth="0" 
      minHeight="0" width="100%" height="100%"> 

    </s:Group> 



</s:Group> 
<s:Button height="15" id="btResize" width="15" 
      bottom="0" right="0" 
      skinClass="spark.skins.spark.windowChrome.GripperSkin" 
      mouseDown="btResize_mouseDownHandler(event)" 
      buttonMode="true"/> 

+0

이 또한 발생합니까? 문서에 따르면 mouseUp 이벤트가 발생하자마자 크기 조정 시퀀스를 멈춰야하는 것처럼 보입니다. mouseUp 수신기 등록 및 등록 해제로 인해 문제가 발생하는지 궁금합니다. 여기를 읽으면 http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/NativeWindow.html#startResize() – shaunhusain

+0

마우스 업 hadler를 제거해도 문제가 항상 종료됩니다. – Flex60460

답변

2

이 문제가 나에게 발생하지 않습니다. AIR 3.1을 대상으로하는 Flex SDK 4.6을 사용하고 있습니다. 그래서 가능한 한 옵션은 4.6이 아닌 경우 SDK를 업그레이드하는 것입니다.

아래 코드는 작동합니다. 내가 thisstage을 변경주의 사항 :와 mouseUp 핸들러를 제거하면

<?xml version="1.0" encoding="utf-8"?> 
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
         xmlns:s="library://ns.adobe.com/flex/spark" 
         xmlns:mx="library://ns.adobe.com/flex/mx"> 

    <fx:Script> 
     <![CDATA[ 
      import mx.events.ResizeEvent; 
      protected function btResize_mouseDownHandler(event:MouseEvent):void 
      { 
       this.nativeWindow.startResize(); 
      } 
     ]]> 
    </fx:Script> 

    <s:Button height="15" id="btResize" width="15" 
       bottom="0" right="0" 
       skinClass="spark.skins.spark.windowChrome.GripperSkin" 
       mouseDown="btResize_mouseDownHandler(event)" 
       buttonMode="true"/> 

</s:WindowedApplication> 
+0

제 경우 this.nativeWindow를 알 수 없으므로 stage.nativeWindow를 전달해야합니다. 그리고 저는 Flex 4.5에서 작업합니다. 그래서 4.6으로 업데이트 해 봅니다. 감사합니다. – Flex60460

+0

학부모 클라스 란 무엇입니까? 전체 MXML 파일을 게시 할 수 있습니까? – eterps