[ActionScript 3.0] AS3.0 马赛克效果

var bmpd:BitmapData;
var matrix:Matrix;
var bmp:Bitmap;
var size:Number = 5;
/**
 * @author:Frost.Yen
 * @E-mail:[email protected]
 */

function mosaic(source:MovieClip,size:Number):void
{
    if (bmpd)
    {
        bmpd.dispose();
    }
    if (matrix)
    {
        matrix = null;
    }
    bmpd = new BitmapData(source.width / size,source.height / size,true,0);
    matrix = new Matrix  ;
    matrix.scale(1 / size, 1 / size);
    bmpd.draw(source, matrix);
    bmp = new Bitmap(bmpd);
    source.addChild(bmp);
    bmp.width = source.width;
    bmp.height = source.height;
}
mc.addEventListener(MouseEvent.CLICK,_chang);
function _chang(e:MouseEvent):void
{
    mosaic(mc,size);
    mc.mouseEnabled = false;
}
时间: 2024-11-09 00:44:33

[ActionScript 3.0] AS3.0 马赛克效果的相关文章

[ActionScript 3.0] AS3.0和AS2.0的相互通信

AS3和AS2之间的通信,最好的方式可能就是LocalConnection了. AS2向AS3发送数据,即AS2调用AS3的函数: as2.0代码(按钮上写的发送信息代码): on (release) { var param = "this message is from as2"; var caller:LocalConnection = new LocalConnection(); caller.send("AS2 send to AS3","funI

[ActionScript 3.0] AS3.0 水面波纹效果

import flash.geom.Point; import flash.display.BitmapData; import flash.filters.DisplacementMapFilter; import flash.display.MovieClip; import flash.events.Event; /** * 创建湖面微波效果 */ function createWater(target:MovieClip):void { var count:int = 1; var po

[ActionScript 3.0] AS3.0 对象在一定范围随机显示不重叠

import flash.geom.Rectangle; import flash.display.MovieClip; import flash.display.Sprite; var arr:Array = []; var dis:Number = 20;//间距 var len:int=15;//对象数量 var bound:Rectangle = new Rectangle(0,0,1000,800);//显示范围 for(var i:int = 0;i<len;i++){ var ob

[ActionScript 3.0] AS3.0 模拟套索工具抠图的两种方法

方法之一:遮罩法 package com.fylibs.tools { import flash.display.Bitmap; import flash.display.BitmapData; import flash.display.DisplayObject; import flash.display.Shape; import flash.display.Sprite; import flash.events.MouseEvent; import flash.geom.Matrix; i

[ActionScript 3.0] AS3.0 生成xml方法之一

var type:Array = ["type0", "type1", "type2"]; var property:Array = [["20","0","1.jpg"], ["60","0","2.jpg"], ["120","0","3.jpg"]];var da

[ActionScript 3.0] AS3.0 Socket通信实例

以下类是充当Socket服务器的例子 package { import flash.display.Sprite; import flash.events.Event; import flash.events.MouseEvent; import flash.events.ProgressEvent; import flash.events.ServerSocketConnectEvent; import flash.net.ServerSocket; import flash.net.Sock

[ActionScript 3.0] as3.0加载as2.0的swf时获取as2.0的实际舞台尺寸

var loader:Loader = new Loader(); loader.contentLoaderInfo.addEventListener(Event.INIT, initHandler); loader.contentLoaderInfo.addEventListener(Event.COMPLETE,completeHandler); loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioErrorH

[ActionScript 3.0] AS3.0根据当天日期获取明天,后天...日期

const dayTime:Number=24*3600*1000//一天毫秒数 var date:Date = new Date(); trace("今天:"+ date.toDateString()); for(var i:int = 2;i<15;i++){ date.setTime(date.valueOf()+dayTime); trace("第"+i+"天:"+ date.toDateString()); }

[ActionScript 3.0] AS3.0 Loader加载子swf时是否需要指定新的应用程序域ApplicationDomain

实际应用中, Loader加载子swf时是否需要指定新的应用程序域ApplicationDomain,需要择情况而定. 1.当加载的子swf中有流存在时,比如视频或者声音,则最好需要指定新的应用程序域ApplicationDomain,如果没有指定,调用_ldr.unloadAndStop();时无法将子swf中的流从内存中卸载掉,了解原因,请深入了解应用程序域ApplicationDomain,代码如下: var ldr:Loader = new Loader(); var context:L