Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

highlight current Index label in list component

Engaged ,
Mar 18, 2013 Mar 18, 2013

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);

}

TOPICS
ActionScript
1.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 18, 2013 Mar 18, 2013

If you mean that the videos play automatically and you want to have the List compoonent's selection change as the videos change then you should be able to use the selectedIndex property of the List component to set it to the next selection.

Just as an example, inside your playNext function...

       playVid(intActiveVid + 1);

       listBox.selectedIndex = intActiveVid + 1;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Mar 19, 2013 Mar 19, 2013

Thankyou.... working good, but after adding next previous buttons that selection not working currectly.

if i click some label, selection is working after if i click next not working selection.

function playNext(e:MouseEvent = null):void {

           if(intActiveVid + 1 < xmlPlaylist..vid.length()){

                              playVid(intActiveVid + 1);

          }

  listBox.selectedIndex = intActiveVid + 1;

}

function playPrevious(e:MouseEvent = null):void {

          if(intActiveVid - 1 >= 0)

playVid(intActiveVid - 1);

listBox.selectedIndex = intActiveVid - 1;

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Mar 19, 2013 Mar 19, 2013

since your property

intActiveVid

is dependend

on the line:

intActiveVid = intVid;

which is only called in

playVid()

(at least as far as this code shows)

you will run into problems if you hit playNext() multipleTimes

you should add sth like,

intActiveVid++

rsp.

intActiveVid--

after the listbox.selectedIndex...Line

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Mar 19, 2013 Mar 19, 2013

I tried but not working perfectly....

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Mar 19, 2013 Mar 19, 2013

forget about my comment; I missed that you called the function inside your if-clause.

You should move

listBox.selectedIndex = intActiveVid + 1

inside the if-clause, though

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Mar 20, 2013 Mar 20, 2013
LATEST

No, i'm facing same problem....

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines