Ver Mensaje Individual
  #4 (permalink)  
Antiguo 21/09/2010, 04:20
juansawyer
 
Fecha de Ingreso: diciembre-2004
Mensajes: 42
Antigüedad: 19 años, 4 meses
Puntos: 0
Respuesta: Barra de la galeria de imagenes mas lenta

Hola, te paso el super-codigo que esta en el primer fotograma del menu thubnails.


Muchas gracias.


// There are fours elements on the stage:
// - the Scroll Bar component that is attached to the thumbnailsMenu Movie Clip and the two buttons

// a) select the Scroll Bar component from the stage / open the Components Inspector Panel and adjust the visible area
// size (viewAreaWidth/viewAreaHeight parameters) and other various parameters or leave them as is since they area already populated
// with default values.

// b) double click the thumbnailsMenu Movie Clip and adjust various menu specific parameters

// Repeat steps a-b (not necessary in this order) till you are satisfied with the results.


// autoPlay PARAMETERS //

//use menu roll over scroll
var useMenuRollOverScroll = 1;

//use selection focus
//var useRowFocus = 1;
//var useRowFocusOverItems = 1; //the focus clip will be place over or behind the items

//use auto play selection
var useAutoPlay = 0;
var autoPlayDelay = 1.5; //auto play checking interval - in seconds

// hide or not the thumb menu scroll bar
var hideScrollBar = 0;


this._parent._alpha = 0;

//auxiliary variables used in autoPlay calculation
var endCurrVideo = 0; // shows if current video ends and next video can start playing

//aux variables used in focus clip calculation
var scrollerIntId;

//aux variables used in autoPlay calculation
var autoPlayIntId;
var totalCells;
var rowsNo;
var pct;
var currPct;
var cellIdx;
var curCell;
var timer;

//aux variables used in rollOver scroll calculation
var menuX = mc1._x;
var menuY = mc1._y;

var firstYOut = 0;
var firstXOut = 0;

// END PARAMETERS //


var imageBox = this._parent.imageBox;
//var loader = this._parent.loaderanim;
//var descriptionBox = imageBox.contentDescriptionBox.contentDescription; //path to description Movie Clip
//var titleBox = imageBox.contentDescriptionBox.contentTitleBox;

//imageBox._visible = false;
//loader._alpha = 0;
//imageBox.contentDescriptionBox._alpha = 0;



// INIT AUTOPLAY METHOD //

function initAutoPlayEngine() {

//check mouse scroll percentage
if (useMenuRollOverScroll) {
sb1.useMouseWheel = "false";
startCheckMouseScroll();
}

//check auto play
initAutoPlayParams(); //init auto play param values used in calculation

if (useAutoPlay) {
startAutoPlay();
}
else {
setPauseState(autoPlayBtn);
}

//BY DEFAULT REVEAL FIRST IMAGE //
//trace("One: "+imageBox["p0"]._name+" "+imageBox["p0"]._alpha+" "+imageBox["p0"]._visible+" "+imageBox._alpha+" "+imageBox._visible);
imageBox["p0"]._visible = true;
imageBox["p0"].contentDescriptionBox._alpha = 0;
imageBox["p0"].contentDescriptionBox._alpha = 0;
//imageBox["p0"].fadeIn();

/*imageBox.imgMc.loadMovie(mc1["p0"]["info"].attributes.bigimage);
titleBox.tf.text = mc1["p0"]["info"].attributes.title;
descriptionBox.tf.htmlText = mc1["p0"]["info"].firstChild.nodeValue;
mc1["p0"]["overShadow"]._alpha = 0;

imageBox._visible = false;
loader._alpha = 100;
imageBox.onEnterFrame = imageBox.preload; */


//create focus rect movie clip inside the table
if (mc1.useRowFocus==1) {
// if (useRowFocusOverItems==1) { mc1.attachMovie("rowFocusRect","focusRect",50000); }
/// else {mc1.attachMovie("rowFocusRect","focusRect",100);} //1000 and up is reserver for images inside the menu
// mc1["focusRect"].swapDepths(0);
// mc1["focusRect"]._width = mc1.focusRectWidth;
// mc1["focusRect"]._height = mc1.focusRectHeight;
}

//reveal content
fade(this._parent,0,100,1);

}


// AUTO PLAY HANDLER //

//called only once after the table is rendered if autoPlay is set to true
function startAutoPlay() {
clearInterval(autoPlayIntId);
autoPlayIntId = setInterval(this,"autoPlay",timer);
endCurrVideo = 1;
}

function stopAutoPlay() {
clearInterval(autoPlayIntId);
}

function autoPlay() {
//trace("auto play: "+endCurrVideo);
if (endCurrVideo==1) { //play/load next video/image only when current video/image ends

var prevCell = curCell; //previous cell mc reference

if (cellIdx == (totalCells - 1)) {
cellIdx = 0;
currPct = 0;

}
else {
cellIdx += 1;
if (cellIdx == (totalCells - 1)) { currPct = 100; }
else {
//currPct += pct;
currPct = cellIdx*pct;
currPct = Math.round(currPct);
}
}

//trace("Next cell: "+cellIdx+" "+currPct);
var curCellName = "p"+cellIdx;
var curCell1 = mc1[curCellName];
//rollOutHandler(prevCell); //roll out previous row
//rollOverHandler(curCell); //roll over the current row
initContent(curCell1); //start playing the current video
//setFocusRect(curCell1); //set focus rect on this cell
startSetScrollBar(); //adjust the scroller position
}
}

function initAutoPlayParams() { //it executes once after the table is rendered
totalCells = mc1.nodes.length;
rowsNo = mc1.nodes.length - 1;
pct = 100 / rowsNo;
curCell = mc1["p0"];
cellIdx = 0;
currPct = 0;
timer = autoPlayDelay * 1000;
if (hideScrollBar==1) sb1._alpha = 0;
//trace(curCell+" "+pct+" "+rowsNo);
}


//restart autoPlay from the current cell position
function restartAutoPlay() {
cellIdx = Number(curCell._name.substr(1,curCell._name.length-1));
//if (!(cellIdx%2)) cellIdx -= 1; //get current selected row index (given by the first cell in the row index)

clearInterval(autoPlayIntId);
autoPlayIntId = setInterval(this,"autoPlay",timer);

}

//autoplay button handlers //
function setPlayState(mc) {
mc.gotoAndStop(1);
restartAutoPlay();
useAutoPlay = 1;
endCurrVideo = 1; //set this to 1 so it can starts playing the next video
}

function setPauseState(mc) {
//trace("set pause");
mc.gotoAndStop(2);
stopAutoPlay();
useAutoPlay = 0;
endCurrVideo = 0;
}

autoPlayBtn.onPress = function() {
//trace("state: "+useAutoPlay);
//0 -> pause state 1 -> play state
if (useAutoPlay == 0) {setPlayState(this);}
else
{setPauseState(this);}
}

prevVideoBtn.onPress = function() {
var cellRef;

//get current selected row index (given by the first cell in the row index)
cellIdx = Number(curCell._name.substr(1,curCell._name.length-1));
//if (!(cellIdx%2)) cellIdx -= 1;

//determine previous cell index
if (cellIdx==0) { cellIdx = totalCells - 1; }
else { cellIdx = cellIdx - 1; }
cellRef = mc1["p"+cellIdx];

//call the press handler with the respective cell mc as parameter
mc1.pressHandler(cellRef);

//set scroll percentage
currPct = Math.round(cellIdx*pct);
//trace(curCell+" "+cellIdx+" "+cellRef+" "+currPct);
startSetScrollBar(); //adjust the scroller position

}

nextVideoBtn.onPress = function() {
var cellRef;

//get current selected row index (given by the first cell in the row index)
cellIdx = Number(curCell._name.substr(1,curCell._name.length-1));
//if (!(cellIdx%2)) cellIdx -= 1;

//determine previous row index -> determined by the first cell index in the row
if (cellIdx==(totalCells - 1)) { cellIdx = 0; }
else { cellIdx = cellIdx + 1; }
cellRef = mc1["p"+cellIdx];

//call the press handler with the respective cell mc as parameter
//trace(cellIdx+" "+cellRef);
mc1.pressHandler(cellRef);

//set scroll percentage
currPct = Math.round(cellIdx*pct);

startSetScrollBar(); //adjust the scroller position

}

// END AUTOPLAY HANDLER //


//SET FOCUS RECT AND SCROLL PERCENTAGE METHODS //
function getRowXY(mc) {

var rowX = mc._x;
var rowY = mc._y;

return Array(rowX,rowY);
}


function setScrollPercentage() {
sb1.scrollPercentage = currPct; //adjust the scroll position
clearInterval(scrollerIntId);
//trace("set scroller2: "+currPct);
}

function startSetScrollBar() {
//trace("set scroller1");
clearInterval(scrollerIntId);
scrollerIntId = setInterval(this,"setScrollPercentage",50);
}


function setFocusRect(mc) {
//trace("set focus rect: "+mc);
if (useRowFocus) {
var res = getRowXY(mc);
var rowX = res[0];
var rowY = res[1];
mc1["focusRect"]._x = rowX;
mc1["focusRect"]._y = rowY;
}
}
//END SET