A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Problem with slideshow gallery

  1. #1
    Junior Member
    Join Date
    Apr 2011
    Posts
    17

    Problem with slideshow gallery

    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.

  2. #2
    Knowledgable n00b BlueGeek's Avatar
    Join Date
    Nov 2006
    Location
    New York City
    Posts
    137
    Can you give a more detailed description of how this is supposed to work? A slideshow is supposed to happen when? How does this relate visually to the gallery? ETC ETC.
    "...there were only two good books in the hotel gift shop and I had written both of them."
    -Douglas Adams

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center