2 Replies Latest reply on Feb 12, 2014 1:00 AM by Marta_dPE

    How can I store the latest member of a random list?

    Marta_dPE Level 1

      Hi there,


      I need some help from you with this behaviour. I need a script to choose a random sound from a list but, each time I click the mouse on member "Speaker" the same audio should be played (only available for 3 times).

      Thanks a million. Marta

      How can I know the selected sound?



      global newsoundlist


      property thisSprite

      property myCounter


      on beginSprite me

        thisSprite = me.spriteNum

        myCounter = 0



      on mouseUp()


        vSound = 0

         soundlist =  ["sound1", "sound2", "sound3", "sound4", "sound5"]

         vRandom = random(5)


      if (_mouse.mouseMember = member("speaker")) then



          myCounter = myCounter + 1



          vPlay = soundlist[vRandom]


          newsoundlist = [vPlay]


          -- sound available only for 3 times


               sound(1). play (member(newsoundlist[1]))


          if myCounter = 4 then


                 sound (1).stop ()


            _player.alert ("Sound no longer available")


          end if



        end if



      end mouseUp