package com.exanimo.gallery { import com.exanimo.gallery.IGallery; import flash.events.TimerEvent; import flash.utils.Dictionary; import flash.utils.Timer; /** * * .. * * @langversion ActionScript 3 * @playerversion Flash 9.0.0 * * @author Eric Eldredge * @author Rich Perez * @author Matthew Tretter * @since 2009.01.12 * */ public class GalleryTimer extends Timer { private var _galleries:Dictionary; public function GalleryTimer(delay:Number = 5000, repeatCount:int = 0) { super(delay, repeatCount); this._init(delay, repeatCount); } public function registerGallery(gallery:IGallery):void { this._galleries[gallery] = 1; } public function unregisterGallery(gallery:IGallery):void { delete this._galleries[gallery]; } private function _init(delay:Number, repeatCount:int):void { this._galleries = new Dictionary(true); this.addEventListener(TimerEvent.TIMER, this._timerHandler); } private function _timerHandler(e:TimerEvent):void { for (var gallery:Object in this._galleries) { var selectedItemIndex:uint = gallery.selectedItemIndex; var nextItemIndex:uint = (selectedItemIndex + 1) % gallery.numItems; gallery.selectItemAt(nextItemIndex); } } } }