≯全屏显示或下载≮
准备写拼图的,没完成,但完成有一些效果,就发部分代码大家看看把../.
复制内容到剪贴板
代码:
import flash.display.BitmapData;
import flash.geom.Rectangle;
import mx.transitions.Tween;
import mx.transitions.easing.*;
var x_num:Number = 4;
var y_num:Number = 4;
var count_num:Number = 0;
var save_depth:Number;
var pic_width:Number = pic._width/x_num;
var pic_height:Number = pic._height/y_num;
var pic_array:Array = new Array();
var bm1:BitmapData = new BitmapData(pic._width, pic._height);
bm1.draw(pic);
pic._visible = false;
var myListener:Object = new Object();
for (var i:Number = 0; i<x_num; i++) {
pic_array[i] = new Array();
for (var j:Number = 0; j<y_num; j++) {
var bm2:BitmapData = new BitmapData(pic_width, pic_height);
bm2.copyPixels(bm1, new Rectangle(j*pic_width, i*pic_height, pic_width, pic_height), new Point(0, 0));
var i_num = 10*i+j;
var j_num = j;
var depth:String = String(i)+String(j);
_root.createEmptyMovieClip("mc"+i+j, 10*i+j);
_root["mc"+i+j].attachBitmap(bm2, this.getNextHighestDepth());
_root["mc"+i+j]._x = j*pic_width;
_root["mc"+i+j]._y = i*pic_height;
pic_array[i].push(depth);
_root["mc"+i+j].depth = pic_array[i][j];
_root["mc"+i+j].onRelease = function() {
if (count_num == 0) {
count_num = 1;
new Tween(this, "_x", Back.easeInOut, this._x, 400, 1, true);
new Tween(this, "_y", Back.easeInOut, this._y, 300, 1, true);
save_depth = this.depth;
}
if (count_num == 1) {
var cinx = this._x;
var ciny = this._y;
new Tween(_root["mc"+save_depth], "_x", Back.easeInOut, 400, cinx, 1, true);
new Tween(_root["mc"+save_depth], "_y", Back.easeInOut, 300, ciny, 1, true);
new Tween(this, "_x", Back.easeInOut, cinx, 400, 1, true);
new Tween(this, "_y", Back.easeInOut, ciny, 300, 1, true);
save_depth = this.depth;
}
};
}
}
Key.addListener(myListener);