2 Replies Latest reply on Dec 18, 2006 10:38 AM by ntsiii

    Voting System

    ojk007 Level 1
      Hey ok so i have a working mp3 player, and now i need to integrate a voting system.

      Heres an overview.
      2apps

      End user
      Server

      End User
      - contains a datagrid with a list of all the songs (music.xml)
      - Is where the user votes for selected song

      Server
      - Is where the songs play
      - Is where the playlist is calculated

      heres my music.xml. note this is one entry on 7000+

      quote:

      <?xml version="1.0" encoding="utf-8"?>
      <files>
      <song>
      <songID>1</songID>
      <name>Is This It</name>
      <artist>The Strokes</artist>
      <album>This is It</album>
      <genre>Unknown</genre>
      <bitrate>224 </bitrate>
      <length>2:35 </length>
      <filename>01 Is This It.mp3</filename>
      <votes>0</votes>
      <played>0</played>
      </song>


      the <votes> and >played tags are where the magic happens.

      i dont know how i can sort through the xml file to find the song with the highest votes. also when the song has been played <played> should = 1. so the datagrid row can be disabled(any suggestions on that as well)

      Now im just starting with flex but i'm not a newbie coder.

      Thanks heaps
        • 1. Re: Voting System
          ntsiii Level 3
          Something like:
          var sSongID:String;
          iHighVote:int = 0;
          var xlSongs:XMLList = xmlData.files.songs;
          for (var i:int=0;i,xlSongs.length();i++) {
          if (xlSongs .votes > iHighVote) {
          iHighVote = xlSongs
          .votes;
          sSongID = xlSongs .songID;
          }

          Tracy
          • 2. Re: Voting System
            ntsiii Level 3
            Arrgh, the forum ate the array brackets.
            Something like:
            var sSongID:String;
            iHighVote:int = 0;
            var xlSongs:XMLList = xmlData.files.songs;
            for (var i:int=0;i,xlSongs.length();i++) {
            if (xlSongs[ i ].votes > iHighVote) {
            iHighVote = xlSongs[ i ].votes;
            sSongID = xlSongs[ i ].songID;
            }

            When the song has played, use the id to find the node, and set the "played" value.

            Tracy