精确选择识别png图片有像素的区域(使用方法)

/**
 *
 * *---------------------------------------*
 * |  ***精确选择识别png图片有像素的区域***  |
 * *---------------------------------------*
 *
 * 编辑修改收录:fengzi(疯子、wu341、wgq341)
 *
 * 不会写代码,我是代码搬运工。
 *
 * 联系方式:QQ(493712833)。
 *
 * 随   笔: https://www.cnblogs.com/fengziwu/
 *
 * 版权协议:请自觉遵守LGPL协议,欢迎修改、复制、转载、传播给更多需要的人。
 * 免责声明:任何因使用此软件导致的纠纷与软件/程序开发者无关。
 * 日   期: 2019.05.08
 *
 * * ------------- 实例 -------------------*
 * 利用InteractivePNG.as类精确选择识别png图片有像素的区域
 * InteractivePNG.as类下载:https://www.cnblogs.com/fengziwu/p/10908764.html
   var pngSp:PNGContainer=new PNGContainer()
   var frame:Shape = new Shape()
   pngSp.x = pngSp.y = 200;
   addChild(pngSp);
   pngSp.addEventListener(MouseEvent.MOUSE_OVER,onPNGOver);
   pngSp.addEventListener(MouseEvent.MOUSE_OUT,onPNGOut);
   function onPNGOver(e:MouseEvent):void
        {
            drawLine(pngSp);
        }

   function onPNGOut(e:MouseEvent):void
        {
            this.removeChild(frame);
        }

   function drawLine(_mc:MovieClip)
        {
            frame.graphics.clear();
            frame.graphics.moveTo(_mc.x,_mc.y);
            frame.graphics.lineStyle(1,0xff00ff);
            frame.graphics.lineTo(_mc.x + _mc.width,_mc.y);
            frame.graphics.moveTo(_mc.x + _mc.width,_mc.y);
            frame.graphics.lineTo(_mc.x + _mc.width,_mc.y + _mc.height);
            frame.graphics.moveTo(_mc.x + _mc.width,_mc.y + _mc.height);
            frame.graphics.lineTo(_mc.x,_mc.y + _mc.height);
            frame.graphics.moveTo(_mc.x,_mc.y + _mc.height);
            frame.graphics.lineTo(_mc.x,_mc.y);
            addChild(frame);
        }
*/

package fengzi.bmd
{
	import flash.display.Loader;
	import flash.events.Event;
	import flash.net.URLRequest;

	
	public class PNGContainer extends InteractivePNG
	{
		private var ldr:Loader = new Loader  ;
		public function PNGContainer()
		{
			ldr.load(new URLRequest("128.png"));
			ldr.contentLoaderInfo.addEventListener(Event.COMPLETE,onPNGLoaded);
		}

		private function onPNGLoaded(e:Event):void
		{
			this.addChild(e.target.content);
		}
	}

}

  

原文地址:https://www.cnblogs.com/fengziwu/p/10908813.html