window.as
ActionScript 2 source for the CubeLogix 3D website, 143 lines: opening a window, growing it to size, and dragging it. Raw file
// 20: sprite 164 frame 1
function showWindow(w, h, mc, title, x, y) {
if (anim) {
return;
}
if (_visible) {
removeMovieClip(wmc);
nmc = mc;
title_text = "";
this.title = title;
animateWindowSize(w, h);
} else {
removeMovieClip(wmc);
nmc = mc;
setWindowSize(70, 40);
_x = x - 45;
_y = y - 30;
this.title = title;
title_text = "";
animateWindowSize(w, h);
}
onEnterFrameCallback = windowFrame;
}
function hideWindow() {
_visible = false;
removeMovieClip(wmc);
onEnterFrameCallback = false;
}
function animateWindowSize(w, h) {
sw = this.w;
sh = this.h;
tw = w;
th = h;
sx = _x;
sy = _y;
tx = _x - (tw - sw) * 0.5;
ty = _y - (th - sh) * 0.5;
anim = true;
anim_start = getTimer();
}
function setWindowSize(w, h) {
this.w = w;
this.h = h;
window_12._width = w + 14 - 40;
window_32._width = w + 14 - 40;
window_13._x = w + 14 - 27;
window_23._x = w + 14 - 7;
window_33._x = w + 14 - 27;
window_21._height = h - 6;
window_23._height = h - 6;
window_31._y = h + 24;
window_32._y = h + 27;
window_33._y = h + 24;
close._x = w + 14 - 52;
drawBlur();
}
function windowFrame() {
if (anim) {
var r8 = 700;
var r9 = getTimer() - anim_start;
if (r9 > r8) {
r9 = r8;
}
var r10 = 0.5 - 0.5 * Math.cos(r9 * 3.1415926 / r8);
var r7 = Math.round(sw * (1 - r10) + tw * r10);
var r6 = Math.round(sh * (1 - r10) + th * r10);
_x = Math.round(sx * (1 - r10) + tx * r10);
_y = Math.round(sy * (1 - r10) + ty * r10);
if (r9 >= r8) {
anim = false;
r7 = tw;
r6 = th;
attachMovie(nmc, "wmc", 1000);
wmc._x = 7;
wmc._y = 27;
title_text = title;
anim2 = true;
anim_start = getTimer();
}
setWindowSize(r7, r6);
_visible = true;
}
if (anim2) {
r8 = 400;
r9 = getTimer() - anim_start;
r10 = 0.5 - 0.5 * Math.cos(r9 * 3.1415926 / r8);
wmc._alpha = 100 * r10;
if (r9 >= r8) {
anim2 = false;
}
}
r7 = Stage.width;
r6 = Stage.height;
var r5 = -r7 * 0.5;
var r4 = -r6 * 0.5;
var r3;
var r2;
if (dragging) {
r3 = start_x + _parent._xmouse - drag_x;
r2 = start_y + _parent._ymouse - drag_y;
} else {
r3 = _x;
r2 = _y;
}
if (r3 > r5 + r7 - getWidth() - 13) {
r3 = r5 + r7 - getWidth() - 13;
}
if (r2 > r4 + r6 - getHeight() - 10) {
r2 = r4 + r6 - getHeight() - 10;
}
if (r3 < r5 + 15) {
r3 = r5 + 15;
}
if (r2 < r4 + 15) {
r2 = r4 + 15;
}
_x = Math.round(r3);
_y = Math.round(r2);
}
function getWidth() {
return w + 14;
}
function getHeight() {
return h + 22 + 27;
}
onEnterFrameCallback = false;
createEmptyMovieClip("mcmask", 2500);
_visible = false;
anim2 = false;
close.onRelease = function() {
hideWindow();
};
window_12.onPress = function() {
dragging = true;
drag_x = _parent._xmouse;
drag_y = _parent._ymouse;
start_x = _x;
start_y = _y;
};
window_12.onRelease = window_12.onReleaseOutside = function() {
dragging = false;
};