欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

巧用Bitmap類制作按鈕

 更新時(shí)間:2007年02月07日 00:00:00   作者:  

最近在制作flash時(shí)需要制作一個(gè)可以隨意設(shè)定寬度的按鈕組件.為了保證按鈕樣式不變形,一般都會(huì)采用將按鈕分成幾個(gè)mc的方法來(lái)制作.但其實(shí),如果對(duì)按鈕的動(dòng)態(tài)效果要求不多的話,完全可以使用Bitmap類來(lái)制作.下面是將按鈕的一個(gè)狀態(tài)分解開來(lái).一般的思路是做為三個(gè)MC,然后在改變寬度是,動(dòng)態(tài)改變中間mc的寬度就可以了。但是這樣的話,對(duì)于元素的制作就比較麻煩.使用bitmap類可以直接將一張圖片分為三個(gè)MC后生成.在批量使用時(shí),效率提高了不少.

方法:

復(fù)制代碼 代碼如下:

/**
 * date  : 2007.2.6
 * author : Frank
 * site  : http://www.2solo.net/log
 */
import flash.display.*;
import flash.geom.Rectangle;
import flash.geom.Point;
install_img("mT_over_bmp", 200, 158, 5, bmp_mc);
function install_img(image_url, center_width, face_width, bar_left, tar_mc) {
 //image_url:目標(biāo)圖片路徑
 //center_width:整體寬度
 //face_width:初始位圖寬度
 //bar_left:邊側(cè)mc寬度
 //tar_mc:所要加載的容器地址
 ///定義原始
 var linkageId:String = image_url;
 var myBD:BitmapData = BitmapData.loadBitmap(linkageId);
 if (tar_mc == undefined || tar_mc == "") {
  tar_mc = this;
 }
 //bmp_mc.attachBitmap(myBD, this.getNextHighestDepth());                                        
 face_width = face_width-2*bar_left;
 ///新建MC
 tar_mc.center_mc.removeMovieClip();
 tar_mc.left_mc.removeMovieClip();
 tar_mc.right_mc.removeMovieClip();
 var center_mc:MovieClip = tar_mc.createEmptyMovieClip("center_mc", tar_mc.getNextHighestDepth());
 var left_mc:MovieClip = tar_mc.createEmptyMovieClip("left_mc", tar_mc.getNextHighestDepth());
 var right_mc:MovieClip = tar_mc.createEmptyMovieClip("right_mc", tar_mc.getNextHighestDepth());
 center_mc._x = bar_left;
 left_mc._x = 0;
 right_mc._x = center_width-bar_left;
 ///新建圖片數(shù)據(jù)
 var myBD_C:BitmapData = new BitmapData(face_width, myBD.height, true, 0x00FF0000);
 var myBD_L:BitmapData = new BitmapData(bar_left, myBD.height, true, 0x00FF0000);
 var myBD_R:BitmapData = new BitmapData(bar_left, myBD.height, true, 0x00FF0000);
 ///拷貝圖片
 myBD_C.copyPixels(myBD, new Rectangle(bar_left, 0, face_width, myBD.height), new Point(0, 0));
 myBD_L.copyPixels(myBD, new Rectangle(0, 0, bar_left, myBD.height), new Point(0, 0));
 myBD_R.copyPixels(myBD, new Rectangle(myBD.width-bar_left, 0, bar_left, myBD.height), new Point(0, 0));
 //加載圖片
 center_mc.attachBitmap(myBD_C, this.getNextHighestDepth());
 left_mc.attachBitmap(myBD_L, this.getNextHighestDepth());
 right_mc.attachBitmap(myBD_R, this.getNextHighestDepth());
 ///調(diào)整距離
 center_mc._width = center_width-2*bar_left;
}
stop();

相關(guān)文章

最新評(píng)論