续之前的柔化后觉得BitmapData函数做到了很多之前做不到的效果了,尤其是在制作画板时需要的吸管工具,在这里只要一行函数就可以取得我们要的顔色了。。真方便啊
[url=http://bbs.flash8.net/bbs/UploadFile/2005-10/2005101023259969.swf]
[color="#373e55"]点击浏览该文件[/color]
[/url]
MovieClip.prototype.smoothImageLoad = function(img) { //柔化圖片
var m = this.createEmptyMovieClip("mc", this.getNextHighestDepth());
var listener = new MovieClipLoader();
listener.onLoadComplete = function(mc:MovieClip) {
mc.onEnterFrame = function() {
var bitmap = new flash.display.BitmapData(this._width, this._height);
bitmap.draw(this);
this.attachBitmap(bitmap, 1, true, true);
this.smoothImageLoadComplete();
updateAfterEvent();
}
};
listener.loadClip(img, m);
};
MovieClip.prototype.pickColor = function() { //取得圖片顔色
var bitmap = new flash.display.BitmapData(this._width, this._height);
bitmap.draw(this);
if(bitmap != undefined) {
var myColor = bitmap.getPixel(this._xmouse, this._ymouse);
return "0x" + myColor.toString(16).toUpperCase();
}
}
this.createEmptyMovieClip("mc", 0);
mc.smoothImageLoad("doggy.jpg");
mc._xscale = mc._yscale=300;
this.onMouseMove = function(){
myColor = mc.pickColor(); //取得圖片的顔色函數
var colorTansform = new flash.geom.ColorTransform();
colorTansform.rgb = myColor;
colorMc.transform.colorTransform = colorTansform;
colorTxt.text = myColor;
updateAfterEvent();
}
本文转自:http://www.5uflash.com/flashjiaocheng/Flashyingyongkaifa/337.html
[url=http://bbs.flash8.net/bbs/UploadFile/2005-10/2005101023259969.swf]
[color="#373e55"]点击浏览该文件[/color]
[/url]
MovieClip.prototype.smoothImageLoad = function(img) { //柔化圖片
var m = this.createEmptyMovieClip("mc", this.getNextHighestDepth());
var listener = new MovieClipLoader();
listener.onLoadComplete = function(mc:MovieClip) {
mc.onEnterFrame = function() {
var bitmap = new flash.display.BitmapData(this._width, this._height);
bitmap.draw(this);
this.attachBitmap(bitmap, 1, true, true);
this.smoothImageLoadComplete();
updateAfterEvent();
}
};
listener.loadClip(img, m);
};
MovieClip.prototype.pickColor = function() { //取得圖片顔色
var bitmap = new flash.display.BitmapData(this._width, this._height);
bitmap.draw(this);
if(bitmap != undefined) {
var myColor = bitmap.getPixel(this._xmouse, this._ymouse);
return "0x" + myColor.toString(16).toUpperCase();
}
}
this.createEmptyMovieClip("mc", 0);
mc.smoothImageLoad("doggy.jpg");
mc._xscale = mc._yscale=300;
this.onMouseMove = function(){
myColor = mc.pickColor(); //取得圖片的顔色函數
var colorTansform = new flash.geom.ColorTransform();
colorTansform.rgb = myColor;
colorMc.transform.colorTransform = colorTansform;
colorTxt.text = myColor;
updateAfterEvent();
}
本文转自:http://www.5uflash.com/flashjiaocheng/Flashyingyongkaifa/337.html