Highlight the button when the slideshow switches slides
Hi All..
i have the slideshow that works perfectly thanks to help from this forum.. the 3 externally loaded SWFs rotate with fade in/outf effect on their own as well as per button click. What I would like to add to it is having the the buttons change appearance (Tint or anything) - just to show which slide the user is currently seeing. I'm very new to AS and I would really appreciate is someone would just point me in a direction of where I should place that function. Thanks so much ahead of time - here's my code:
// Attach Music
var req:URLRequest = new URLRequest("squeeak3.mp3");
var sound:Sound = new Sound();
var controller:SoundChannel = new SoundChannel();
var b:Boolean;
if(!b) {
b=true;
function soundLoaded(event:Event):void
{
controller = sound.play(0,1000);
play_btn.addEventListener(MouseEvent.CLICK, playSound);
stop_btn.addEventListener(MouseEvent.CLICK, stopSound);
}
function playSound(event:MouseEvent):void
{
SoundMixer.stopAll();
controller = sound.play(0,1000);
}
function stopSound(event:MouseEvent):void
{
controller.stop();
SoundMixer.stopAll();
}
sound.addEventListener(Event.COMPLETE, soundLoaded);
sound.load(req);
}
//Import classes for easier use
import fl.transitions.Tween;
import fl.transitions.TweenEvent;
import fl.transitions.easing.*;
//Timer
var tl:MovieClip = this;
var slideDuration:uint = 8000;// or use whatever
var slideTimer:Timer=new Timer(slideDuration,0);
slideTimer.addEventListener(TimerEvent.TIMER,autoAdvanceF);
var previousBtn:SimpleButton;
var btnA:Array = [one_btn,two_btn,three_btn];
function autoAdvanceF(e:TimerEvent):void {
nextButtonF(previousBtn).dispatchEvent(new MouseEvent(MouseEvent.CLICK));
}
function nextButtonF(btn:SimpleButton):SimpleButton {// use class type of your buttons
for (var i:uint=0; i<btnA.length; i++) {
if (btnA==btn) {
return btnA[(i+1)%btnA.length];
}
}
return null;
}
//Load external SWF into main
var Xpos:Number = 0;
var Ypos:Number = 0;
var loaderA:Array = [];
//Btns universal function (whenver any button is clicked, the loader will be removed
function btnClick(event:MouseEvent):void {
slideTimer.reset();
slideTimer.start();
previousBtn = SimpleButton(event.currentTarget);
var loader:Loader = new Loader();
loaderA.push(loader);
var newSWFRequest:URLRequest = new URLRequest("swfs/" + event.target.name + ".swf");
loader.contentLoaderInfo.addEventListener(Event.COMPLETE,loadComplete );
loader.load(newSWFRequest);
loader.x = Xpos;
loader.y = Ypos;
loader.alpha = 0;
addChildAt(loader,0);
}
var tween:Tween;
function loadComplete(e:Event):void {
for (var i:int=loaderA.length-2; i>=0; i--) {
tl["tween_"+i] = new Tween(loaderA, "alpha", None.easeIn, loaderA.alpha, 0, 1, true);
tl["tween_"+i].addEventListener(TweenEvent.MOTION_FINISH,onMotionFinish);
//
}
e.target.loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, loadComplete);
tween = new Tween(e.target.loader, "alpha", None.easeIn, 0, 1, 1, true);
}
function onMotionFinish(e:TweenEvent) {
Loader(e.target.obj).unload();
removeChild(e.target.obj);
loaderA.splice(loaderAIndex(Loader(e.target.obj)),1);
e.target.obj = null;
}
function loaderAIndex(loader:Loader):int{
for(var i:int=0;i<loaderA.length;i++){
if(loaderA==loader){
return i;
}
}
return -1;
}
/// Button Listerners
one_btn.addEventListener(MouseEvent.CLICK,btnClick);
two_btn.addEventListener(MouseEvent.CLICK,btnClick);
three_btn.addEventListener(MouseEvent.CLICK,btnClick);
btnA[0].dispatchEvent(new MouseEvent(MouseEvent.CLICK));