调整窗口大小
问题描述:
我有一个带夹子的窗口皮肤。 Gripper用于调整窗口的大小,以监听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"/>
所以,我很欣赏,你的帮助。
感谢
PS:整个代码
<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"/>
答
此行为不会对我来说发生。我正在使用以SDK 3.1为目标的Flex 3.1。所以一个选项(如果可能的话)是升级你的SDK,如果它不是4.6。
下面的代码也适用。请注意,我改变了stage
到this
:
<?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>
有,如果您删除mouseUp处理,这也发生?根据文档,它看起来应该停止调整序列,只要它得到一个mouseUp事件,我想知道你的注册和注销mouseUp监听器是否导致某种问题。根据这里阅读http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/NativeWindow.html#startResize() – shaunhusain 2012-02-07 22:07:20
即使我删除mouseup哈勒,问题总是退出。 – Flex60460 2012-02-07 22:28:11