Hi, I'm trying to create a slideshow in a gallery. I managed to make it work but only if you first click on the slideshow button and then you click on one of the thumbnails. I haven't been able to do just by clicking on the slideshow button. This is the code I used in summary:
Code:
package galery {
public class GaleriaFotos{
public function GaleriaFotos() {
this.thumbList = new Array();
this._timer = new Timer(1500);
this._timer.addEventListener(TimerEvent.TIMER, onTimerEvent, false, 0, true);
}
private function init():void
{
if (_imageCount == 0)
{
for each(var b:BitmapAsset in AssetFilter.getImage(this.assets))
{
if (b.id.indexOf(Datos.SUFIJO_SMALL) != -1)
{
var name:String = b.id.replace(Datos.PREFIJO_FOTO, "").replace(Datos.SUFIJO_SMALL);
var index:int = parseInt(name);
thumbList[index] = b;
}
_imageCount++;
}
}
Tweener.addTween(this, { alpha:1, time:1.5, transition:"easeOutQuad" } );
//slideshow button
thumbs.slide_mc.buttonMode = true;
thumbs.slide_mc.addEventListener(MouseEvent.CLICK, doSlideShow);//función en la linea 465
//thumbs click
for (var i:int = 1; i < 8; i++)
{
var thumb:ThumbHolder = thumbs.getChildByName("t" + i) as ThumbHolder;
thumb.buttonMode = true;
thumb.addEventListener(MouseEvent.CLICK, onThumbClick, false, 0, true);
}
}
private function onThumbClick(e:MouseEvent):void
{
var tHolder:ThumbHolder = e.currentTarget as ThumbHolder;
cargarFoto(tHolder.fotoId);
cualFoto = tHolder.fotoId;
}
private function cargarFoto(i:int):void
{
var foto:BitmapAsset = BitmapAsset(assets[Datos.PREFIJO_FOTO + i.toString()]);
_currentImage = i;
if (foto.content == null)
{
foto.addEventListener(AssetEvent.ASSET_COMPLETE, resizePhoto, false, 0, true);
foto.load();
}
else
{
mostrarFoto(foto.content);
}
}
private function doSlideShow(e:Event):void
{
this._timer = new Timer(1000);
this._timer.addEventListener(TimerEvent.TIMER, onSlide, false, 0, true);
cualFoto ++;
}
private function onSlide(e:Event):void
{
cargarFoto(cualFoto);
cualFoto ++;
}
private function onTimerEvent(e:TimerEvent):void
{
ocultarControles();
}
private function hideControls()
{
Tweener.addTween(thumbs, { alpha: 0, time: 1, transition: "easeOutQuad", onComplete:function() { _timer.stop(); } } );
}
private function showControls(event:MouseEvent)
{
if (barra.alpha < 1)
{
Tweener.addTween(thumbs, { alpha: 1, time: 1, onComplete:function() { _timer.reset(); _timer.start(); } } );
}
}
}
}
What have I do to make it work correctly?
Thank you.