Ver Mensaje Individual
  #8 (permalink)  
Antiguo 22/11/2007, 03:31
Avatar de zaida
zaida
 
Fecha de Ingreso: noviembre-2006
Ubicación: Madrid (España)
Mensajes: 266
Antigüedad: 17 años, 5 meses
Puntos: 0
Re: mover fotogramas clave en la linea de tiempo

Código:
				if (page.position == null) continue;
			}
			var ratio	= page.shadeRatio;
			mc._xscale	= (ratio * setting.sizeMax + (1-ratio) * setting.sizeMin) / 100 * width * page.side;
			mc._alpha	= ratio * setting.alphaMax + (1-ratio) * setting.alphaMin;
		}
	};

//PUBLIC METHODS
	//resize the page
	public.resizePage = function (width, height) {
		if (width != null && !isNaN(width)) this._pageWidth = Number(width);
		if (height != null && !isNaN(height)) this._pageHeight = Number(height);
		var width			= this._pageWidth;
		var height			= this._pageHeight;
		var adjustEven		= this._adjustEvenPage;
		for (var i in this._pages) {
			if (this._flipPages[i] != null) continue;
			var page		= this._pages[i];
			page.page._x	= !adjustEven ? width * -page.side : page.side<0 ? 0 : -width;
			if (page.rearPage != null) page.rearPage._x = !adjustEven ? page.page._x : page.side<0 ? width : 0;
			this._adjustPage(page);
			this._adjustFlipSize(page);
			this.handleEvent("onResizePage", page, width, height);
		}
		for (var i in this._flipPages) {
			var page		= this._pages[i];
			page.page._x	= !adjustEven ? width * -page.side : page.side<0 ? 0 : -width;
			if (page.rearPage != null) page.rearPage._x = !adjustEven ? page.page._x : page.side<0 ? width : 0;
			var pos			= page.position;
			if (pos.top < 0) {
				page.page._y		= -height;
				page.rearPage._y	= -height;
			}
			if (pos.trackMouse == null) {
				pos.aimX	= width * (pos.x < 0 ? -1 : 1);
				pos.aimY	= pos.top > 0 ? 0 : height;
			}
			this._adjustPagePos(page);
			this._adjustFlipSize(page);
			this.handleEvent("onResizePage", page, width, height);
		}
	};
//set the sizes of the flip areas
	public.setFlipSize = function (width, height, innerWidth, innerHeight) {
		var flipSize	= typeof(width) == "object" ? width
						: {width:width, height:height, innerWidth:innerWidth, innerHeight:innerHeight};
		for (var i in this._flipSize) {
			if (flipSize[i] != null && !isNaN(flipSize[i])) this._flipSize[i] = Number(flipSize[i]);
		}
		for (var i in this._pages) this._adjustFlipSize(this._pages[i]);
	};

	//start to flip the page at the specified index by the certain corner
	public.startFlip = function (index, corner, aimX, aimY) {
		//validate page
		index			= int(index);
		var pages		= this._pages;
		var page		= pages[index];
		if (page == null) return false;
		var side		= page.side;
		if (side < 0 ? index <= this._firstPage : index >= this._lastPage) return false;
		corner			= {top:1, bottom:-1, topInner:2, bottomInner:-2}[corner];
		if (corner == null) corner = 1;
		//create new flipped page
		var width		= this._pageWidth;
		var height		= this._pageHeight;
		var curPage		= this._curPage;
		var flipped		= this._flipCount;
		var topDepth	= this._topPageDepth;
		if (flipped != 0) {
			//there's flipped pages
			var s		= flipped < 0 ? -1 : 1;
			if (index < curPage + (s<0 ? flipped*2 : 0) || index > curPage+1 + (s<0 ? 0 : flipped*2)) return false;
			var f		= curPage + (s<0 ? 0 : 1);
			var top		= pages[f + s].position.top;
			if (corner != top * (side == s ? 1 : 2)) return false;
			if (index == f + flipped*2) {
				//flip the outter corner page
				if (!this._multiFlip) return false;
				flipped			= this._flipCount = flipped + s;
				var n			= (this._visiblePages + flipped * s - 1) * 2;
				this._createPage(f + n * s, topDepth-n - (s<0 ? 0 : 1));
				page			= this._createPage(f-s + flipped*2, topDepth + flipped*s,
								  {x:width*s, y:top>0 ? 0 : height, top:top});
			} else if (index == f - s) {
				//flip the opposite page
				if (!this._multiFlip) return false;
				f				= (this._curPage -= 2*s) + (s<0 ? 0 : 1);
				flipped			= this._flipCount = flipped + s;
				var n			= (this._visiblePages - 1) * 2;
				var m			= flipped * s * 2;
				this._createPage(f, 0);
				for (var i = n+m; i >= 0; i -= 2) pages[f + i*s].swapDepths(topDepth-i - (s<0 ? 0 : 1));
				for (var i = m; i >= 2; i -= 2) pages[f + (i-1)*s].swapDepths(topDepth + i/2);
				this._createPage(f - (1+n)*s, 0);
				for (var i = 0; i <= n; i += 2) pages[f - (i+1)*s].swapDepths(topDepth-i - (s<0 ? 1 : 0));
				page			= pages[f + s];
				page.position	= {x:-width*s, y:top>0 ? 0 : height, top:top};
				this._adjustPage(page);
			} else if (side == s) {
				//flip the flipped page
				page			= pages[index + s];
			}
		} else {
			//there's no flipped page
			if (index < curPage || index > curPage+1) return false;
			var f		= curPage + (side<0 ? 0 : 1);
			var n		= this._visiblePages * 2;
			if (Math.abs(corner) == 1) {
				//flip at outter corner
				flipped			= this._flipCount = side;
				this._createPage(f + n * side, topDepth - n - (side<0 ? 0 : 1));
				page			= this._createPage(f + side, topDepth + 1,
								  {x:width*side, y:corner > 0 ? 0 : height, top:corner});
			} else {
				//flip at inner corner
				flipped			= this._flipCount = -side;
				for (var i = n; i >= 2; i -= 2) pages[f - (i-1)*side].swapDepths(topDepth-i - (side<0 ? 1 : 0));
				f				= (this._curPage += 2*side) + (side<0 ? 0 : 1);
				this._createPage(f - side, topDepth + (side<0 ? -1 : 0));
				page.swapDepths(topDepth + 1);
				page.position	= {x:width*side, y:corner > 0 ? 0 : height, top:corner/2};
				this._adjustPage(page);
				this._createPage(f + (n - 2) * side, 0);
				for (var i = 0; i <= n - 2; i += 2) pages[f + i*side].swapDepths(topDepth-i - (side<0 ? 0 : 1));
			}
		}
//set flipped page
		this._adjustFlipSize(page);
		var pos			= page.position;
		pos.trackMouse	= aimX == null;
		pos.aimX		= aimX == null ? this._xmouse : Number(aimX);
		pos.aimY		= aimX == null ? this._ymouse : Number(aimY);
		this._flipPages[page.index]	= page;
		this.handleEvent("onStartFlip", page);
		return true;
	};

	//stop a flipped page, if index is null, all flipped page will be stoped, side can be 'left' or 'right'
	public.stopFlip = function (index, finish, side) {
		var flipped			= this._flipCount;
		if (flipped == 0) return false;
		//stop all flipped pages
		if (index == null) {
			if (finish) {
				while (this._flipCount != 0) {
					for (var i in this._flipPages) this.stopFlip(i, true);
				}
			} else {
				for (var i in this._flipPages) this.stopFlip(i);
			}
			return true;
		}
		//set the aim position
		index		= int(index);
		index		-= flipped < 0 ? (index%2 == 0 ? 1 : 0) : (index%2 == 0 ? 0 : -1);
		var page	= this._flipPages[index];
		var pos		= page.position;
		if (pos == null) return false;
		if (pos.trackMouse != null) {
			pos.trackMouse		= null;
			side				= {left:-1, right:1}[side];
			pos.aimX			= this._pageWidth * (side != null ? side : pos.x < 0 ? -1 : 1);
			pos.aimY			= pos.top > 0 ? 0 : this._pageHeight;
		}
		if (!finish) {
			this.handleEvent("onStopFlip", page);
			return true;
		}
		//finish flipping
		var side	= page.side;
		var n		= this._visiblePages * 2;
		if (pos.aimX * side > 0 && index == this._curPage + (side > 0 ? -1 : 2)) {
			//flip to the face side
			var pages			= this._pages;
			var topDepth		= this._topPageDepth;
			var m				= flipped * -side * 2;
			this._removePage(pages[index + side]);
			this._removePage(pages[index + n*side]);
			for (var i = n-2; i >= 0; i -= 2) pages[index + i*side].swapDepths(topDepth-i - (side>0 ? 1 : 0));
			for (var i = 2; i < n+m; i += 2) pages[index + (1-i)*side].swapDepths(topDepth-i + (side>0 ? 2 : 1));
			for (var i = 2; i < m; i += 2) pages[index - i*side].swapDepths(topDepth + i/2);
			this._curPage		-= 2 * side;
			this._flipCount	+= side;
			delete this._flipPages[index];
			page.position		= null;
			this.handleEvent("onFinishFlip", page);
			this._adjustPage(page);
			this._adjustFlipSize(page);
		} else if (pos.aimX * side < 0 && index == this._curPage + (side > 0 ? 1 : 0) + flipped*2) {
			//flip to the corner side
			this.handleEvent("onFinishFlip", page);
			this._removePage(page);
			this._removePage(this._pages[index - (n - 1) * side]);
			this._adjustPage(this._pages[index + side]);
		} else {
			return false;
		}
		return true;
	};
sigue:
__________________
-- Cuando sientas miedo y no tengas un hombro dónde apoyarte, no te hundas en la soledad, pues si lo haces fracasarás --