有没有办法在AS3 Flex Air桌面应用程序中捕获鼠标滚轮事件?
我使用的是FlashBuilder 4.7,FlexSDK 4.6和Air 15.0
我在下面尝试但没有成功。没有反应或反应不顺畅(但不经常)。
<?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"
applicationComplete="windowedapplication1_applicationCompleteHandler(event)"
mouseWheel="onMouseWheel(event)">
<fx:Script>
<![CDATA[
import mx.events.FlexEvent;
protected function windowedapplication1_applicationCompleteHandler(event:FlexEvent):void
{
systemManager.addEventListener(MouseEvent.MOUSE_WHEEL, onMouseWheel);
stage.addEventListener(MouseEvent.MOUSE_WHEEL, onMouseWheel);
}
private function onMouseWheel(e:MouseEvent):void{
trace(e.type + " " + e.delta);
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
</s:WindowedApplication>
和-app.xml
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<application xmlns="http://ns.adobe.com/air/application/15.0">
<id>MouseTest</id>
<filename>MouseTest</filename>
<name>MouseTest</name>
<versionNumber>0.0.0</versionNumber>
<initialWindow>
<content>[This value will be overwritten by Flash Builder in the output app.xml]</content>
<autoOrients>false</autoOrients>
<fullScreen>false</fullScreen>
<visible>false</visible>
</initialWindow>
</application>
由于
答案 0 :(得分:0)
尝试创建一个包含一些内容的组,并在那里拥有鼠标监听器。
一般情况下,鼠标滚轮可以很好地使用flex组件,不知道你的代码有什么问题我的猜测是你没有在屏幕上绘制任何东西以捕获鼠标滚轮事件或者它不应该添加到窗口应用程序组件。