1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
| function drawOutline(mc, width, height) {
var wallx = width/2+10;
var wally = height/2+10;
var offset = 4;
// Shadow
mc.beginFill(0x000000, 20);
mc.moveTo(-wallx+offset, -wally+offset);
mc.lineTo(wallx+offset, -wally+offset);
mc.lineTo(wallx+offset, wally+offset);
mc.lineTo(-wallx+offset, wally+offset);
mc.lineTo(-wallx+offset, -wally+offset);
// Outline
mc.beginFill(0xFFFFFF, 100);
mc.lineStyle(2, 0x333333, 100);
mc.moveTo(-wallx, -wally);
mc.lineTo(wallx, -wally);
mc.lineTo(wallx, wally);
mc.lineTo(-wallx, wally);
mc.lineTo(-wallx, -wally);
mc.endFill();
}
// ----------------------
// build placeholders
// ----------------------
loads = [];
stack = [];
depth = 9999;
for (i=0; i<nodes.length; i++) {
attrs = nodes[i].attributes;
img = _root.createEmptyMovieClip("image"+i, depth--);
drawOutline(img, attrs.width, attrs.height);
img.createEmptyMovieClip("imgholder", 1);
img.imgholder._x = -attrs.width/2;
img.imgholder._y = -attrs.height/2;
img.imgholder.src = attrs.src;
totalw += img._width;
totalh += img._height;
coverw = (img._width>coverw) ? img._width : coverw;
coverh = (img._height>coverh) ? img._height : coverh;
img._rotation = (Math.random()*16)-8;
img._visible = false;
img._alpha = 0;
stack.push(img);
loads.push(img);
}
stack[0]._rotation = 0;
gox = (totalw/nodes.length)*0.9;
goy = (-totalh/nodes.length)*0.4;
// ----------------------
// load images
// ----------------------
function loadimage(id) {
if (loads[id]) {
loads[id]._visible = true;
loads[id].imgholder.loadMovie(loads[id].imgholder.src);
loads[id].imgholder.onLoad = function() {
loads[id].imgholder.onEnterFrame = function() {
if (this._parent._alpha<75) {
this._parent._alpha += 25;
} else if (this._parent._alpha<100) {
this._parent._alpha += 25;
loadimage(id+1);
} else {
delete this.onEnterFrame;
}
};
};
}
}
loadimage(0);
// ----------------------
// handle swap
// ----------------------
_root.createEmptyMovieClip("Cover", 10000);
Cover.beginFill(0xFFFFFFF, 0);
Cover.moveTo(-coverw/2, -coverh/2);
Cover.lineTo(coverw/2, -coverh/2);
Cover.lineTo(coverw/2, coverh/2);
Cover.lineTo(-coverw/2, coverh/2);
Cover.lineTo(-coverw/2, -coverh/2);
Cover.endFill();
Cover.onRelease = function() {
// Shuffle the top image to the side
stack[0].t = 0;
stack[0].rot = stack[0]._rotation;
stack[0].changerot = (Math.random()*16)-8-stack[0].rot;
stack[0].onEnterFrame = function() {
this.t++;
this._x = Math.easeInQuad(this.t, 0, gox, 6);
this._y = Math.easeInQuad(this.t, 0, goy, 6);
this._rotation = Math.easeInQuad(this.t, this.rot, this.changerot, 6);
if (this.t == 7) {
this.swapDepths(depth--);
this.t = 0;
this.onEnterFrame = function() {
this.t++;
this._x = Math.easeOutQuad(this.t, gox, -gox, 6);
this._y = Math.easeOutQuad(this.t, goy, -goy, 6);
if (this.t == 6) {
delete this.onEnterFrame;
}
};
}
};
// Rotate the next image into view
stack[1]._x = stack[1]._y=0;
stack[1].t = 0;
stack[1].rot = stack[1]._rotation;
stack[1].onEnterFrame = function() {
this.t++;
this._rotation = Math.easeOutQuad(this.t, this.rot, -this.rot, 6);
if (this.t == 6) {
delete this.onEnterFrame;
}
};
// Move top image to the back of the stack array
var addback = stack.shift();
stack.push(addback);
}; |
Partager