
22/11/2007, 03:26
|
 | | | Fecha de Ingreso: noviembre-2006 Ubicación: Madrid (España)
Mensajes: 266
Antigüedad: 18 años, 3 meses Puntos: 0 | |
Re: mover fotogramas clave en la linea de tiempo
Código:
//draw mask with specified type, a, b is the side width of the corner
private._drawMask = function (mask, type, a, b) {
var w = this._pageWidth;
var h = this._pageHeight;
mask.clear();
mask.beginFill(0, 20);
mask.moveTo(type <= 1 || type > 10 ? 0 : w, 0);
mask.lineTo(type > 10 ? w - a : a, 0);
switch (type) {
case 0: //triangle (flip page)
mask.lineTo(0, b);
break;
case 1: //quadrangle (flip page)
mask.lineTo(b, h);
mask.lineTo(0, h);
break;
case 2: //quadrangle
mask.lineTo(b, h);
break;
case 12: //quadrangle (shadow)
mask.lineTo(w - b, h);
break;
case 3: //pentagon
mask.lineTo(0, b);
mask.lineTo(0, h);
break;
case 13: //pentagon (shadow)
mask.lineTo(w, b);
mask.lineTo(w, h);
break;
}
if (type > 1) {
mask.lineTo(type < 10 ? w : -w, h);
mask.lineTo(type < 10 ? w : -w, 0);
}
if (type <= 1 || type > 10) mask.lineTo(0, 0);
mask.endFill();
};
//reset the flip areas in the specified page
private._setFlipArea = function (page) {
if (page.side < 0) {
var name1 = ["leftTopInner", "leftBottomInner", "leftTop", "leftBottom"];
} else {
var name1 = ["rightTopInner", "rightBottomInner", "rightTop", "rightBottom"];
}
var name2 = ["faTopInner", "faBottomInner", "faTop", "faBottom"];
var width = -page.side * this._flipSize.width / 100 * this._pageWidth;
var height = this._flipSize.height / 100 * this._pageHeight;
var innerWidth = -page.side * this._flipSize.innerWidth / 100 * this._pageWidth;
var innerHeight = this._flipSize.innerHeight / 100 * this._pageHeight;
for (var i = 0; i < 4; i++) {
if (this._flipArea[name1[i]]) {
var fa = page[name2[i]];
if (fa == null) {
fa = page[name2[i]] = page.face.attachMovie("HotArea", "FlipArea"+i, this._flipAreaDepth+i);
fa.onPress = this._faPress;
fa.onRelease = this._faRelease;
fa.onReleaseOutside = this._faRelease;
fa.enabled = this._active;
}
fa._y = i%2 == 0 ? 0 : this._pageHeight;
fa._xscale = i > 1 ? width : innerWidth;
fa._yscale = (i%2 == 0 ? 1 : -1) * (i > 1 ? height : innerHeight);
} else if (page[name2[i]] != null) {
page[name2[i]].removeMovieClip();
page[name2[i]] = null;
}
}
this.handleEvent("onSetFlipArea", page);
};
//adjust the size of the flip areas in the specified page
private._adjustFlipSize = function (page) {
var name = ["faTopInner", "faBottomInner", "faTop", "faBottom"];
var pageHeight = this._pageHeight;
var width = -page.side * this._flipSize.width / 100 * this._pageWidth;
var height = this._flipSize.height / 100 * pageHeight;
var innerWidth = -page.side * this._flipSize.innerWidth / 100 * this._pageWidth;
var innerHeight = this._flipSize.innerHeight / 100 * pageHeight;
for (var i = 0; i < 4; i++) {
var fa = page[name[i]];
if (fa == null) continue;
fa._y = (i%2 == 0 ? 0 : pageHeight) - (page.position.top < 0 ? pageHeight : 0);
fa._xscale = i > 1 ? width : innerWidth;
fa._yscale = (i%2 == 0 ? 1 : -1) * (i > 1 ? height : innerHeight);
}
};
//onPress event handler of flip areas
private._faPress = function () {
this._parent._parent.main.startFlip(this._parent._parent.index,
{FlipArea0:"topInner", FlipArea1:"bottomInner", FlipArea2:"top", FlipArea3:"bottom"}[this._name]);
};
//onPress event handler of flip areas
private._faRelease = function () {
this._parent._parent.main.stopFlip(this._parent._parent.index);
};
//onMouseMove event handler
private._onMouseMove = function () {
var mx = this._xmouse;
var my = this._ymouse;
for (var i in this._flipPages) {
var pos = this._pages[i].position;
if (pos.trackMouse) {
pos.aimX = mx;
pos.aimY = my;
}
}
};
//adjust position according to the neighbour pages
private._adjustPagePos = function (page) {
var pos = page.position;
if (pos == null) return;
var range = this._getMaskRange(-page.side*pos.x, pos.top>0 ? pos.y : this._pageHeight-pos.y);
var innerRange = this._flipPages[page.index + 2*page.side].position.range;
var outterRange = this._flipPages[page.index - 2*page.side].position.range;
var a = range.a;
var b = range.b;
var type = range.type;
if (innerRange != null) {
if (a > innerRange.a) a = innerRange.a;
if (type > innerRange.type) {
type = innerRange.type;
b = innerRange.b;
} else if (type == innerRange.type && b > innerRange.b) {
b = innerRange.b;
}
}
if (outterRange != null) {
if (a < outterRange.a) a = outterRange.a;
if (type < outterRange.type) {
type = outterRange.type;
b = outterRange.b;
} else if (type == outterRange.type && b < outterRange.b) {
b = outterRange.b;
}
}
if (a == range.a && b == range.b && type == range.type) {
pos.range = range;
} else {
var angle = (type == 0 ? Math.atan2(b, a) : Math.atan2(this._pageHeight, a - b)) * 2;
pos.range = this._getMaskRange(this._pageWidth - a * (1-Math.cos(angle)), a * Math.sin(angle));
}
this._adjustPage(page);
};
//set the settings of boundary shade or page shadow
private._shadeSetting = function (name, value) {
var mcName = {_shade:"shade", _pageShadow:"shadow"}[name];
var setting = this[name];
if (value.show != null) setting.show = value.show ? true : false;
if (value.color != null) setting.color = parseInt(value.color) & 0xffffff;
var rangeName = {sizeMin:0, sizeMax:1, alphaMin:2, alphaMax:3};
for (var i in rangeName) {
if (value[i] != null) setting[i] = value[i] > 0 ? Number(value[i]) : 0;
}
var width = this._pageWidth;
for (var i in this._pages) {
var page = this._pages[i];
var mc = page[mcName];
if (!setting.show && mc != null) {
mc.removeMovieClip();
mc = page[mcName] = null;
}
if (!setting.show) return;
if (mc == null) {
mc = name == "_shade"
? (page.shade = page.face.attachMovie("PageShade", "ShadeMC", this._shadeDepth))
: (page.shadow = page.attachMovie("PageShade", "ShadowMC", this._shadowDepth));
}
(new Color(mc)).setRGB(setting.color);
if (name == "_shadow") {
mc._visible = page.position != null;
sigue
__________________ -- Cuando sientas miedo y no tengas un hombro dónde apoyarte, no te hundas en la soledad, pues si lo haces fracasarás -- |