highlight current Index label in list component
Hi,
I'm writhing http xml video playlist. i was took 'List' component for playlist.
if i click on label, that is working (i mean playing video & highlighting label).
but after video ending, video automatically playing but label not highlighting, How can i highlight current playing video label?
Code:
var videoURL:String = "playlist_http.xml";
var bolLoaded:Boolean;;
var intActiveVid:int;
var urlLoader:URLLoader;
var urlRequest:URLRequest;
var xmlPlaylist:XML;
var nConnection:NetConnection;
var ns:NetStream;
var video:Video = new Video();
nConnection = new NetConnection();
nConnection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
nConnection.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
nConnection.connect(null);
function connectStream():void
{
ns = new NetStream(nConnection);
ns.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, ayncErrorHandler);
ns.checkPolicyFile = true;
ns.client = this;
vidDisplay.attachNetStream(ns);
ns.play(videoURL);
vidDisplay.smoothing = true;
urlRequest = new URLRequest(videoURL);
urlLoader = new URLLoader();
urlLoader.addEventListener(Event.COMPLETE, playlistLoaded);
urlLoader.load(urlRequest);
}
function netStatusHandler(event:NetStatusEvent):void
{
trace(event.info.code);
switch (event.info.code)
{
case "NetConnection.Connect.Success" :
connectStream();
break;
case "NetConnection.Connect.Closed" :
break;
case "NetStream.Play.Stop" :
playNext();
break;
default :
}
}
function securityErrorHandler(event:SecurityErrorEvent):void
{
trace("securityErrorHandler: " + event);
}
function ayncErrorHandler(event: AsyncErrorEvent):void
{
//Nothing
}
//PlayList SetUp
//=====================
var listBox:List = new List();
addChild(listBox);
listBox.setSize(194, 339);
listBox.move(484,0);
function playlistLoaded(e:Event):void {
xmlPlaylist = new XML(urlLoader.data);
//trace(xmlPlaylist.vid[0].@src);
for (var i:int=0;i<xmlPlaylist.vid.length();i++) {
listBox.addItem({label:xmlPlaylist.vid.attribute("desc"), data:xmlPlaylist.vid.@src});
listBox.addEventListener(Event.CHANGE, playVidlist);
listBox.selectedIndex = 0;
}
// set source of the first video but don't play it
playVid(0, false);
if(!bolLoaded) {
ns.play(videoURL);
bolLoaded = true;
}
else{
ns.resume();
}
}
function playVidlist(e:Event):void
{
//intActiveVid=int(String(e.currentTarget.selectedItem.data));
ns.play(String(e.currentTarget.selectedItem.data));
lblDescription.text = e.currentTarget.selectedItem.label;
if(!bolLoaded) {
ns.play(videoURL);
bolLoaded = true;
}
else{
ns.resume();
}
}
function playVid(intVid:int = 0, bolPlay = true):void {
if(bolPlay) {
// play requested video
ns.play(String(xmlPlaylist..vid[intVid].@src));
} else {
videoURL = xmlPlaylist..vid[intVid].@src;
}
lblDescription.text = String(xmlPlaylist..vid[intVid].@desc);
// update active video number
intActiveVid = intVid;
}
function playNext(e:MouseEvent = null):void {
if(intActiveVid + 1 < xmlPlaylist..vid.length()){
playVid(intActiveVid + 1);
}
}
function playPrevious(e:MouseEvent = null):void {
// check if we're not and the beginning of the playlist and go back
if(intActiveVid - 1 >= 0)
playVid(intActiveVid - 1);
}
