views:

46

answers:

2

Hi,

I'm using a PHP Script to create XML. Which pulls through the data from a Database.

I have an video list, which pulls through X amount of videos. But I want to show them 5 at a time. I want to hide a button once it reaches the amount of videos in the XML.

Hope there's enough detail in this question. My script is as follows.....

            // Event Handler
        protected function videoRetrieval_resultHandler(event:ResultEvent):void {

            var videoData:ArrayCollection = event.result.videos.video;

            var viddata:Videoinfo;

             for each (var vid:Object in videoData)
             {
                 viddata = new Videoinfo();

                 viddata.id = vid.id;
                 viddata.title = vid.title;
                 viddata.thumbnail = vid.thumbnail;
                 videos.addItem(viddata);
             }
        }
protected function button1_clickHandler(event:MouseEvent):void
        {
            // Handle the button
            videoArea.verticalScrollPosition += 5;
            videoArea.liveScrolling = true;
        }

        protected function button2_clickHandler(event:MouseEvent):void
        {
            //Handle the button
            videoArea.verticalScrollPosition -= 5;
            videoArea.liveScrolling = true;
        }

I need an IF statement in there to check the number of videos in the XML file and show or hide the relevant button too.

Thanks in advance.

+2  A: 

Well if you are using PHP to pull the videos out of a database and populate an XML with all the video, in that same PHP script you can just count the number of videos and add that to your XML.

Something like this would work:

<videos count="56"> ... </videos>

where "count" is total number of videos in the XML, then just retrieve that value in your even handler and store it in a class variable.

Or else, considering you are doing a loop on each video in you for each in the videoRetrieval_resultHandler handler, you can get the video count there too.

__dominic
Thanks _dominic. Not a bad idea... Worked too
StuBlackett
glad I could help
__dominic
A: 

I am not sure I got your question correctly, but if the issue is just to check the count of the video then it would be,

var count:int = (video..videos).length(); 

assuming your root note is and video uri residing in

HTH

anand