[AS3]as3.0处理加载透明gif,png图片代码示例(3)
packageking.loadAphaImage{ /* QQ:334973991 */ importflash.display.*; importflash.events.*; publicclassDealImage{ publicstaticfunctiondealImage(sprite:Sprite){ sprite.addEventListener(MouseEvent.MOUSE
- package king.loadAphaImage{
- /*
- QQ: 334973991
- */
- import flash.display.*;
- import flash.events.*;
- public class DealImage{
- public static function dealImage(sprite:Sprite){
- sprite.addEventListener(MouseEvent.MOUSE_DOWN,mouseDownHandle);
- sprite.addEventListener(MouseEvent.MOUSE_MOVE,mouseMoveHandle);
- sprite.addEventListener(MouseEvent.MOUSE_OUT,mouseOutHandle);
- sprite.addEventListener(MouseEvent.MOUSE_OVER,mouseOverHandle);
- sprite.addEventListener(MouseEvent.MOUSE_UP,mouseUpHandle);
- sprite.addEventListener(MouseEvent.CLICK,mouseClickHandle);
- }
- private static function mouseDownHandle(events:MouseEvent):void {
- var sprite:Sprite=events.currentTarget as Sprite;
- if(checkIsApha(events))sprite.dispatchEvent(new MouseEvent("IMAGE_MOUSE_DOWN"));
- }
- private static function mouseMoveHandle(events:MouseEvent):void {
- var sprite:Sprite=events.currentTarget as Sprite;
- if(checkIsApha(events))sprite.dispatchEvent(new MouseEvent("IMAGE_MOUSE_MOVE"));
- }
- private static function mouseOutHandle(events:MouseEvent):void {
- var sprite:Sprite=events.currentTarget as Sprite;
- if(checkIsApha(events))sprite.dispatchEvent(new MouseEvent("IMAGE_MOUSE_OUT"));
- }
- private static function mouseOverHandle(events:MouseEvent):void {
- var sprite:Sprite=events.currentTarget as Sprite;
- if(checkIsApha(events))sprite.dispatchEvent(new MouseEvent("IMAGE_MOUSE_OVER"));
- }
- private static function mouseUpHandle(events:MouseEvent):void {
- var sprite:Sprite=events.currentTarget as Sprite;
- if(checkIsApha(events))sprite.dispatchEvent(new MouseEvent("IMAGE_MOUSE_UP"));
- }
- private static function mouseClickHandle(events:MouseEvent):void {
- var sprite:Sprite=events.currentTarget as Sprite;
- if(checkIsApha(events))sprite.dispatchEvent(new MouseEvent("IMAGE_MOUSE_CLICK"));
- }
- private static function checkIsApha(events:MouseEvent):Boolean{
- var sprite:Sprite=events.currentTarget as Sprite;
- if((sprite.getChildAt(0) as Bitmap).bitmapData.getPixel32(events.localX,events.localY)){
- return true;
- }
- return false;
- }
- }
- }
热门文章推荐
- [HLS]做自己的m3u8点播系统使用HTTP Live Streaming(HLS技术)
- [FMS]FMS流媒体服务器配置与使用相关的介绍
- [AS3]什么是M3U8,与HTML5的区别是什么
- AS2.0 让flash自适应全屏,并且不自动缩放
- [AS3]as3.0的sound类常用技巧整理
- [AS3]as3与ByteArray详解、ByteArray介绍、ByteArray用法
- 关于RTMP,RTMPT,RTMPS,RTMPE,RTMPTE协议的介绍
- [JS]分享浏览器弹出窗口不被拦截JS示例
请稍候...