这就是局势。 I m 为一个项目建立一个5.5点的闪电网站,为一页的外围,我想将背景形象变成随机的片段,然后把下一个框架装上。 (在CS3中,有这样做的时间表效果,但被cs4+删除)。 我发现AS2的文字是为了探索图像(与Tweener.as V1.33(为AS2)一起),但任何人都知道如何与AS3合作? 增 编
Code follows:
import flash.display.BitmapData;
import flash.geom.Rectangle;
import flash.geom.Point;
import caurina.transitions.Tweener;
//
var container:MovieClip = this.createEmptyMovieClip("container_mc", this.getNextHighestDepth());
var bmp:BitmapData = BitmapData.loadBitmap("careca");
var grid:Number = 20;
var rect:MovieClip;
var depth:MovieClip = this;
var spacement:Number = 0;
var count:Number = 0;
var rows:Number = 0;
var a:Number, b:Number, c:Number, d:Number;
var rects:MovieClip = depth.createEmptyMovieClip("rects_mc", depth.getNextHighestDepth());
var pieces:Array = new Array();
//
container.attachBitmap(bmp, container.getNextHighestDepth());
container._visible = false;
//
function init() {
create();
}
function randRange(min:Number, max:Number) {
var randomNum:Number = Math.round(Math.random()*(max-min+1)+(min-.5));
return randomNum;
}
function clearBitmaps() {
rects.swapDepths(0);
rects.removeMovieClip();
}
function create() {
for (a=1; a<=Math.round(container._height/grid); a++) {
drawLine();
rows++;
}
rects._x = Stage.width/2-rects._width/2;
rects._y = Stage.height/2-rects._height/2;
}
function drawLine() {
for (b=0; b<Math.round(container._width/grid); b++) {
rect = rects.createEmptyMovieClip("rect"+String(rows)+String(b)+"_mc", rects.getNextHighestDepth());
bmp[i] = new BitmapData(grid, grid, true);
//
bmp[i].copyPixels(bmp, new Rectangle(grid*b, grid*rows, grid, grid), new Point(0, 0));
rect.attachBitmap(bmp[i], rect.getNextHighestDepth());
rect.initX = (rect._width+spacement)*b;
rect.initY = (rect._height+spacement)*rows;
rect.randomX = randRange(-Stage.width, Stage.width);
rect.randomY = randRange(-Stage.height, Stage.height);
rect.randomRotation = randRange(10, 360);
rect.randomScale = randRange(0, 100);
rect.randomAlpha = 0;
rect.cacheAsBitmap = true;
rect._x = rect.initX;
rect._y = rect.initY;
//
pieces.push(rect);
}
setTimeout(animPieces, 1000);
}
function animPieces() {
for (c=0; c<pieces.length; c++) {
rect = pieces[c];
Tweener.addTween(rect, {_scale:rect.randomScale, _rotation:rect.randomRotation, _x:rect.randomX, _y:rect.randomY, _alpha:0, time:5, transition:"easeOutExpo", onComplete:clearBitmaps});
}
}
//
init()
Source : Lemlinh.com