SoFunction
Updated on 2025-04-11

Use Bitmap class to make buttons


/**
 * date  : 2007.2.6
 * author : Frank
 * site  : http:///log
 */
import .*;
import ;
import ;
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: Target image path
//center_width: Overall width
//face_width: Initial bitmap width
//bar_left: mc width on the side
//tar_mc: The container address to be loaded
///Define the original
 var linkageId:String = image_url;
 var myBD:BitmapData = (linkageId);
 if (tar_mc == undefined || tar_mc == "") {
  tar_mc = this;
 }
 //bmp_mc.attachBitmap(myBD, ());                                        
 face_width = face_width-2*bar_left;
/// Create a new 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;
/// Create new picture data
 var myBD_C:BitmapData = new BitmapData(face_width, , true, 0x00FF0000);
 var myBD_L:BitmapData = new BitmapData(bar_left, , true, 0x00FF0000);
 var myBD_R:BitmapData = new BitmapData(bar_left, , true, 0x00FF0000);
///Copy the picture
 myBD_C.copyPixels(myBD, new Rectangle(bar_left, 0, face_width, ), new Point(0, 0));
 myBD_L.copyPixels(myBD, new Rectangle(0, 0, bar_left, ), new Point(0, 0));
 myBD_R.copyPixels(myBD, new Rectangle(-bar_left, 0, bar_left, ), new Point(0, 0));
//Load the picture
 center_mc.attachBitmap(myBD_C, ());
 left_mc.attachBitmap(myBD_L, ());
 right_mc.attachBitmap(myBD_R, ());
///Adjust the distance
 center_mc._width = center_width-2*bar_left;
}
stop();