flash 原生UI 与 starling 鼠标事件冲突解决办法
2014-11-20 14:29
411 查看
package com.util.core.commands
{
import com.game.ui.main.WindowState;
import flash.display.Stage;
import flash.events.MouseEvent;
/**
* 作用于判断是否点击到原生的FLASH UI 界面 如果是的话就不向starling 发送 点击事件 如果不是的话则继续发送事件
* @author Administrator
*
*/
public class StarlingEventShield
{
public function StarlingEventShield()
{
}
static public var mouseDown:Boolean = false;
static public var mouseDrag:Boolean = false;
static private var stage:Stage;
static public function activate( stage:Stage ) : void
{
if ( StarlingEventShield.stage ) return;
StarlingEventShield.stage = stage;
stage.addEventListener( MouseEvent.MOUSE_DOWN, onStage_MouseDown, false, 1, true );
stage.addEventListener( MouseEvent.MOUSE_UP, onStage_MouseUp, false, 1, true );
}
static private function onStage_MouseDown(e:MouseEvent):void
{
if(WindowState.windows == WindowState.MFightWindow)
{
if(e.target == MClient.client)
{
mouseDown = true;
}else
if ( e.target != stage ) e.stopImmediatePropagation();
else mouseDown = true;
}
}
static private function onStage_MouseMove(e:MouseEvent):void
{
if ( mouseDown ) mouseDrag = true;
if ( e.target != stage && !mouseDrag ) e.stopImmediatePropagation();
}
static private function onStage_MouseUp(e:MouseEvent):void
{
if(WindowState.windows == WindowState.MFightWindow)
{
if ( e.target != stage && !mouseDrag ) e.stopImmediatePropagation();
mouseDown = mouseDrag = false;
}
}
static public function deactivate() : void
{
if ( !stage ) return;
stage.removeEventListener( MouseEvent.MOUSE_DOWN, onStage_MouseDown );
stage.removeEventListener( MouseEvent.MOUSE_UP, onStage_MouseUp );
mouseDown = mouseDrag = false;
stage = null;
}
}
}
在项目中出现过当前问题本来以为在程序里面用事件截断处理就可以不会出现事件渗透到starling,而且在pc上是可以实现当前的目标。
但是
真正在移动设备上使用的时候就不是那么简单的了。事件还是能够被starling监控到。咋办呢--直接上源码吧 这也是在一个外文的网站上看到的一个代码哪个网址不记得了不好意思。
希望能够帮助到其他人吧。
{
import com.game.ui.main.WindowState;
import flash.display.Stage;
import flash.events.MouseEvent;
/**
* 作用于判断是否点击到原生的FLASH UI 界面 如果是的话就不向starling 发送 点击事件 如果不是的话则继续发送事件
* @author Administrator
*
*/
public class StarlingEventShield
{
public function StarlingEventShield()
{
}
static public var mouseDown:Boolean = false;
static public var mouseDrag:Boolean = false;
static private var stage:Stage;
static public function activate( stage:Stage ) : void
{
if ( StarlingEventShield.stage ) return;
StarlingEventShield.stage = stage;
stage.addEventListener( MouseEvent.MOUSE_DOWN, onStage_MouseDown, false, 1, true );
stage.addEventListener( MouseEvent.MOUSE_UP, onStage_MouseUp, false, 1, true );
}
static private function onStage_MouseDown(e:MouseEvent):void
{
if(WindowState.windows == WindowState.MFightWindow)
{
if(e.target == MClient.client)
{
mouseDown = true;
}else
if ( e.target != stage ) e.stopImmediatePropagation();
else mouseDown = true;
}
}
static private function onStage_MouseMove(e:MouseEvent):void
{
if ( mouseDown ) mouseDrag = true;
if ( e.target != stage && !mouseDrag ) e.stopImmediatePropagation();
}
static private function onStage_MouseUp(e:MouseEvent):void
{
if(WindowState.windows == WindowState.MFightWindow)
{
if ( e.target != stage && !mouseDrag ) e.stopImmediatePropagation();
mouseDown = mouseDrag = false;
}
}
static public function deactivate() : void
{
if ( !stage ) return;
stage.removeEventListener( MouseEvent.MOUSE_DOWN, onStage_MouseDown );
stage.removeEventListener( MouseEvent.MOUSE_UP, onStage_MouseUp );
mouseDown = mouseDrag = false;
stage = null;
}
}
}
在项目中出现过当前问题本来以为在程序里面用事件截断处理就可以不会出现事件渗透到starling,而且在pc上是可以实现当前的目标。
但是
真正在移动设备上使用的时候就不是那么简单的了。事件还是能够被starling监控到。咋办呢--直接上源码吧 这也是在一个外文的网站上看到的一个代码哪个网址不记得了不好意思。
希望能够帮助到其他人吧。
相关文章推荐
- flash 原生UI 与 starling 鼠标事件冲突解决办法
- frameset 将截断键盘和鼠标事件的问题解决办法
- 关于flex里面mousedown 和click事件冲突问题的解决办法
- js鼠标单击和双击事件冲突问题的解决方法
- 做项目过程中遇到的问题及解决----UIGesture手势与UI控件点击的事件冲突解决
- gridview中单元格button的点击事件和onitemclick点击冲突及解决办法
- ListView中的Item点击事件和子控件的冲突或者item点击没有反应的解决办法
- 【js】碰到了Flash与extjs冲突无法输入中文解决办法。
- NGUI 触摸UI和人物行走冲突的解决办法
- 鼠标滑过网页上的flash文件时出现虚框额解决办法
- UITapGestureRecognizer和UIButton的点击事件冲突的解决办法
- wpf Canvas 对鼠标事件不响应的解决办法
- 【事件冲突】ScrollView嵌套ViewPager冲突的解决办法
- UITapGestureRecognizer和UIButton的点击事件冲突的解决办法
- flash解决png透明区域不响应鼠标事件 as3.0
- js鼠标单击和双击事件冲突问题的解决方法
- CEGUI 鼠标双击事件 解决办法
- 关于flex里面mousedown 和click事件冲突问题的解决办法
- 在ListView中的Text添加spannableString 点击事件与ListView的OnItemClick事件冲突的解决办法
- 关于flex里面mousedown 和click事件冲突问题的解决办法