I’m stumped so I’ll try and explain my problem briefly.
I’ve created an XML based video player that incorporates a player window and a scrolling play list of video thumbnails.
Videos are selected and loaded in one of two ways…by selecting a thumbnail or by advancing the videos using a “next” or a “previous” button.
All of this works perfectly…however…
I’ve decided to track which video is playing by displaying a “currently playing” graphic on the video’s corresponding thumbnail in the playlist. (BTW, I created the scrolling playlist with AS3 rather than using the Flash playlist component)
I am able to achieve the desired effect when a playlist item is selected by tracking which thumb is clicked and storing it as an object…then executing this code:
/******************** SELECT VIDEO FUNCTION ************************/
var currentMovieId:Number = 0; // tracks position in video array //
var theBtn:DisplayObject
var theBtnEnabled:Object
var lastBtn:DisplayObject;
var lastBtnEnabled:Object;
function selectMovie(event:MouseEvent = null):void {
currentMovieId = event.target.name;
theBtn = event.target.HiLite.currently_playing as DisplayObject;
theBtnEnabled = theBtn as Object;
theBtn.removeEventListener(MouseEvent.CLICK, selectMovie);
theBtn.removeEventListener(MouseEvent.MOUSE_OVER, changeColorOver_moreVids);
theBtn.removeEventListener(MouseEvent.MOUSE_OUT, changeColorOut_moreVids);
theBtnEnabled.buttonMode = false;
TweenMax.to(theBtn, 0.5, {alpha:1});
if (lastBtn != null) {
lastBtnEnabled.buttonMode = true;
TweenMax.to(lastBtn, 0.5, {alpha:0});
lastBtn.addEventListener(MouseEvent.CLICK, selectMovie);
lastBtn.addEventListener(MouseEvent.MOUSE_OVER, changeColorOver_moreVids);
lastBtn.addEventListener(MouseEvent.MOUSE_OUT, changeColorOut_moreVids);
}
lastBtn = theBtn;
lastBtnEnabled = theBtnEnabled;
updateMovie(); // loads the selected movie //
}
What I am having difficulty figuring out is how to update the “currently playing” thumbnail when I advance the video using the “next” and “previous” buttons. The code for those buttons is the following:
******************* NEXT VIDEO FUNCTION ***********************
function nextMovie(event:MouseEvent = null):void {
currentMovieId = currentMovieId + 1;
if (currentMovieId == totalEntries) { // totalEntries is the xml.length //
currentMovieId = 0;
}
}
/******************** PREVIOUS VIDEO FUNCTION ************************/
function prevMovie(e:MouseEvent = null):void {
if (currentMovieId == 0) {
currentMovieId = totalEntries - 1;
} else {
currentMovieId = currentMovieId - 1;
}
updateMovie();
}
I’ve tried placing the button tracking code in it’s own function and adding a fake click event to the “next” and “previous” buttons without success. I know that I need to increase or decrease the value of theBtn by one but I’m just now sure how to track this from outside of the “selecMovie” function. I feel that this must be simpler than I am making it but, I’m brain dead and begging for some help.
I hope I was clear (if not overly wordy). If anyone needs more explanation, just ask and, if you can point me in the right direction, even better.
Thanks in advance.