您的位置:首页 > 其它

旋转图像时候强迫光滑

2008-02-16 10:08 246 查看
导读:

forceSmoothing

强迫光滑属性
在FLASH里进行伸缩和旋转是很容易的,只要使用_rotation,_xscale,成员。除非你发布一个FB8或者更新的SWF媒体内容,你伸缩或者旋转的每一张图片都会被锯齿化,非常讨厌。为了消除这一点你必须将媒体内容发布为FLASH7获得使用复杂的loadBitmapSmoothed 函数。
当FLASH8.5播放器发布时,他引入一个forceSmoothing 属性,该属性在AS2中也存在,现在我们所做的就是当装载图片的时侯将此属性设置为TRUE,当然不要忘记在FLASH播放器8.5以前的版本中该做法是没有任何效果。
这样做得到的效果很好,下面有一个例子展示这种做法。

Rotating and scaling pictures in flash is easy. Just use _rotation, _xscale and _yscale. Except when you publish an swf for Flash Player 8 or newer. Every image you rotate or scale will become jagged. Very anoying. To remedy this you can either publish for Flash 7 or use a complicated loadBitmapSmoothed function that uses BitmapData.

When Flash Player 8.5 came out it introduced the forceSmoothing property. This property is also available in as2. Now all we need to do is set it to true when we load images. Don’t forget that this will have no effect in Flash players older than version 8.5!

It works quite well. In the example below you can clearly see the left picture is more jagged than the right one.

var so = new SWFObject("http://www.crydust.be/blog/wp-content/uploads/forcesmoothing.swf", "forcesmoothing_swf", "400", "200", "9", "#FFFFFF");
so.addParam("base", ".");
so.write("forcesmoothing");

var outer_mc = this.createEmptyMovieClip("outer_mc", 0);
var inner_mc = outer_mc.createEmptyMovieClip("inner_mc", 0);

// don't rotate the inner_mc
// it will lose its properties when the image is loaded
outer_mc._rotation = 45;
outer_mc._xscale = 120;
outer_mc._yscale = 60;

var mcl:MovieClipLoader = new MovieClipLoader();

mcl.addListener({
  onLoadInit: function(target:MovieClip){
    // this prevents that awfully jagged look
    target.forceSmoothing = true;
  }
});

mcl.loadClip("image.jpg", inner_mc);


本文转自
http://www.crydust.be/blog/2008/02/15/forcesmoothing/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: