当我在 Flash Professional CS6 中将事件侦听器添加到舞台时:
stage.addEventListener(MouseEvent.RIGHT_MOUSE_DOWN, rightMouseHandler);
或没有常数:
stage.addEventListener("rightMouseDown", rightMouseHandler);
鼠标右键工作正常。我在 Flash Player 11.7 (flashplayer_11_sa_debug.exe)、Firefox、Chrome、Internet Explorer 中对此进行了测试。
但是当我在 Fash Builder 4.6 - Flex 4.6 应用程序类型 Web 中编写此代码时:
stage.addEventListener("rightMouseDown", rightMouseHandler);
鼠标右键不起作用。
.
默克斯
以 AIR 应用程序类型运行的相同 Flex 项目使鼠标右键正常工作。
关于为什么不在 Flash Player 中工作的任何想法?
^^^编辑:^^^ 我如何添加监听器:
闪存生成器 4.6:
<s:Application applicationComplete="completeHandler()" ...>
<fx:Script>
<![CDATA[
private function completeHandler(): void {
stage.addEventListener("rightMouseDown", rightMouseHandler);
}
public function rightMouseHandler(e :MouseEvent) :void {
var col :String = '#' + uint(Math.random()*0xFFFFFF).toString(16);
setStyle('backgroundColor', col);
trace(col);
}
1 帧中的 Flash Professional CS6:
stage.addEventListener("rightMouseDown", rightMouseHandler);
function rightMouseHandler(e :MouseEvent) :void{
var col :uint = uint(Math.random()*0xFFFFFF);
stage.color = col;
trace('#' + col.toString(16));
}