Como adicionar botões anterior e próximo nesse código
Eae galera to com uma dificuldade muito grande para adicionar o botao anterior e proximo nesse codigo, para que ele mostre a imagem que foi vista antes e depois.
tentei fazer mas o botao nao aparece mesmo eu colocando a layer do botao como primeira. Espero que possam me ajudar.
import fl.containers.UILoader;
import caurina.transitions.*;
//---------loading the external xml file-------
var urlRequest:URLRequest = new URLRequest("bpics.xml");
var urlLoader:URLLoader = new URLLoader();
var myXML:XML = new XML();
var xmlList:XMLList;
myXML.ignoreWhitespace = true;
urlLoader.addEventListener(Event.COMPLETE,fileLoaded);
urlLoader.load(urlRequest);//--------holds the paths to the thumbnails-------
var arrayURL:Array = new Array();
//--------holds the paths to the big photos-------
var arrayName:Array = new Array();
//--------holds the thumbnail objects-------
var holderArray:Array = new Array();
//--------represents the number of collumns-------
var nrColumns:uint = 5;
//-------represents the container of our gallery
var sprite:Sprite = new Sprite();
addChild(sprite);
var thumb:Thumbnail;//-------- the thumbnails container-------
var thumbsHolder:Sprite = new Sprite();
sprite.addChild(thumbsHolder);//-------- the photoLoader container-------
var loaderHolder:Sprite = new Sprite();
//loaderHolder.graphics.beginFill(0x000000,1);
//loaderHolder.graphics.drawRect(0,0,570,330);
//loaderHolder.graphics.endFill();
loaderHolder.x = 0;
loaderHolder.alpha = 100;
loaderHolder.y = 0;
sprite.addChild(loaderHolder);//-------- loads the big photo-------
var photoLoader:UILoader = new UILoader();
photoLoader.width = 577;
photoLoader.height = 300;
photoLoader.y = 0;
photoLoader.x = 0;
photoLoader.buttonMode = true;
photoLoader.addEventListener(MouseEvent.CLICK,onClickBack);
loaderHolder.addChild(photoLoader);
/* we loop through the xml file
populate the arrayURL, arrayName and position the thumbnalis*/
function fileLoaded(event:Event):void {
myXML = XML(event.target.data);
xmlList = myXML.children();
for (var i:int=0; i<xmlList.length(); i++) {
var picURL:String = xmlList[i].url;
var picName:String = xmlList[i].big_url;
arrayURL.push(picURL);
arrayName.push(picName);
holderArray[i] = new Thumbnail(arrayURL[i],i,arrayName[i]);
holderArray[i].addEventListener(MouseEvent.CLICK,onClick);
holderArray[i].name = arrayName[i];
holderArray[i].buttonMode = true;
//if (i<nrColumns) {
holderArray[i].y = 313;
holderArray[i].x = i*65+10;
//} else {
//holderArray[i].y = holderArray[i-nrColumns].y+110;
//holderArray[i].x = holderArray[i-nrColumns].x;
//}
thumbsHolder.addChild(holderArray[i]);
}
showPicture(holderArray[0].name);
}//----handles the Click event added to the thumbnails--
function onClick(event:MouseEvent):void {
showPicture(event.currentTarget.name);
}
function showPicture(source:String):void{
photoLoader.source = source;
loaderHolder.alpha = 0;
//Tweener.addTween(thumbsHolder, {x:0, time:1, transition:"easeInLinear"});
Tweener.addTween(loaderHolder, {x:0, time:1, transition:"easeInLinear"});
Tweener.addTween(thumbsHolder, {alpha:1, time:1, transition:"linear"});
Tweener.addTween(loaderHolder, {alpha:1, time:1, delay:1, transition:"linear"});
}
//----handles the Click event added to the photoLoader----
function onClickBack(event:MouseEvent):void {
//Tweener.addTween(thumbsHolder, {x:0, time:1, transition:"easeInLinear"});
Tweener.addTween(loaderHolder, {x:0, time:1, transition:"easeInLinear"});
Tweener.addTween(thumbsHolder, {alpha:1, time:2, transition:"linear"});
Tweener.addTween(loaderHolder, {alpha:0, time:2, transition:"linear"});
}
thumbsHolder.mask = maskk2;
photoLoader.mask = maskk;
addEventListener(Event.ENTER_FRAME, enterFrameHandler);
function enterFrameHandler(event:Event):void {
var placing:int = thumbsHolder.x;
if ((placing + (300-mouseX)/10) >= -1*thumbsHolder.width+620)
{
//Tweener.addTween(thumbsHolder, {x:(thumbsHolder.x + (300-mouseX)/5), time:0.2, transition:"linear"});
placing = placing + (300-mouseX)/5;
} else {
placing = -1*thumbsHolder.width+620
}
if ((placing + (300-mouseX)/10) < 30)
{
placing = placing + (300-mouseX)/5;
} else {
placing = 30
}
Tweener.addTween(thumbsHolder, {x:placing, time:1, transition:"easeOutLinear"});
}
Esse acima eh o codigo dai adicionei isso:
function ant (Event:MouseEvent){
if (i>0){
showPicture(holderArray[i-1].name);
}
else {
showPicture(holderArray[0].name);
}
}
function prox (Event:MouseEvent){
if (i>0){
showPicture(holderArray[i+1].name);
}
else {
showPicture(holderArray[0].name);
}
}
this.anterior.addEventListener(MouseEvent.CLICK, ant);
this.proximo.addEventListener(MouseEvent.CLICK, prox);Discussão (11)
Carregando comentários...