我正在尝试对加载loadclip()
的图像进行平滑处理
我找到了平滑功能,它只适用于位于_level0
的动画片段,例如_level0.mc
,但我想让孩子MC平滑,例如_level0.parent_mc.children_mc
,然后成像只是消失。
平滑功能:
here = this; // trace(here) == _level0
bg_smooth = function (bg):Void {
var bg_depth:Number = bg.getDepth();
var bg_name:String = bg._name;
var bg_parent = bg._parent;
var bg_bitmap_temp:BitmapData = new BitmapData(bg._width, bg._height, true, 0x00FFFFFF);
bg_bitmap_temp.draw(bg);
removeMovieClip(bg);
bg_parent.createEmptyMovieClip(bg_name,bg_depth);
here[bg_name].bitmapObj = bg_bitmap_temp.clone();
bg_bitmap_temp.dispose();
here[bg_name].attachBitmap(here[bg_name].bitmapObj,1,"auto",true);
};
其他代码:
var loader:MovieClipLoader = new MovieClipLoader();
var mclL:Object = new Object();
mclL.onLoadProgress = function(target, loadedBytes, totalBytes) {
//trace(Math.round((loadedBytes / totalBytes) * 100) + "%");
};
loader.addListener(mclL);
mclL.onLoadInit = function(element) {
bg_smooth(element); // trace(element) == _level0.mc or _level0.parent_mc.children_mc
};
loader.loadClip("img/image.jpg", mc); // <= works
//loader.loadClip("img/image.jpg", parent_mc.children_mc); // <= not works
也试图写_level0.parent_mc['children_mc']
代替parent_mc.children_mc
并制作here == _level0.parent_mc
- 仍然没有运气。如果我在加载完成时删除bg_smooth(element)
,那么一切正常,但当然平滑已禁用。
答案 0 :(得分:1)
我找到了另一个工作功能。对其他人可能有帮助。
function applySmoothing(target:MovieClip) {
var mcParent:MovieClip = target._parent;
var mcName:String = target._name;
var myBitmap:BitmapData = new BitmapData(target._width, target._height);
myBitmap.draw(target);
target.removeMovieClip();
target.attachBitmap(myBitmap, 1, "auto", true);
}