Toggle Switch

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • meaningless
    Forum Member
    • May 2003
    • 9

    Toggle Switch

    I searched the forums about info on toggle switches but was unable to get any solid info on how to create one so I will ask here.

    what I want is to use one button to turn on/off the the looping of mp3's. can anyone post some sample code that might help me in doing this ???
  • Corey
    Indigo Rose Staff Alumni
    • Aug 2002
    • 9745

    #2
    Re: Toggle Switch

    That's easy, create 2 images, one for each toggle state, and align them. Put actions on each image to hide itself and show the other (plus appropriate MP3 related actions for your scenario). Set your page to hide image 2 OnShow.

    Corey Milner
    Creative Director, Indigo Rose Software

    Comment

    • meaningless
      Forum Member
      • May 2003
      • 9

      #3
      Re: Toggle Switch

      Thanks for the help it works fine but can this be done using just one button for both actions ???

      Comment

      • meaningless
        Forum Member
        • May 2003
        • 9

        #4
        Re: Toggle Switch

        What I need is something that works off of an IF statement because I have other code that needs to run if the looping value equals true and not to run if it equals false.

        Comment

        • Corey
          Indigo Rose Staff Alumni
          • Aug 2002
          • 9745

          #5
          Re: Toggle Switch

          Absolutely, that's the beauty of AMS, there's at least 3 different ways to do practically everything. [img]/ubbthreads/images/icons/smile.gif[/img]

          Corey Milner
          Creative Director, Indigo Rose Software

          Comment

          • meaningless
            Forum Member
            • May 2003
            • 9

            #6
            Re: Toggle Switch

            And how would one go about doing it the other 2 ways ?

            Thx...

            Comment

            • kpsmith
              Forum Member
              • Jul 2000
              • 332

              #7
              Re: Toggle Switch

              You could use a hotspot to control the actions and the button image to be displayed.

              Create a hospot the size of your button
              Place the 2 different images inside the hotspot with no actions
              Now create the appropriate actions for the hotspot. For example something like:

              ONCLICK Action for Hotspot

              IF (%Loop% = "True")
              %Loop% = "False"
              Page.HideObject ("Loop ON")
              ELSE
              %Loop% = "True"
              Page.ShowObject ("Loop ON")
              END IF

              Comment

              • Corey
                Indigo Rose Staff Alumni
                • Aug 2002
                • 9745

                #8
                Re: Toggle Switch

                Actually the first method is easier than that. In general it's not a good idea to use 3 objects where 2 would do just as well.

                Corey Milner
                Creative Director, Indigo Rose Software

                Comment

                • meaningless
                  Forum Member
                  • May 2003
                  • 9

                  #9
                  Re: Toggle Switch

                  I am reading through the helpfile for the MP3.SetRepeat function and it says


                  You can use a variable in this field to set the MP3 player's repeat state according to the value in that variable.

                  I am not sure what this is trying to say because I set the value of the MP3.SetRepat to %loop% and it does not do anything.

                  where exactly do I set this variable and how can i determine if it's on or off

                  Comment

                  • Corey
                    Indigo Rose Staff Alumni
                    • Aug 2002
                    • 9745

                    #10
                    Re: Toggle Switch

                    Well you can use a dialog to display the value of any variable for troubleshooting or reference. And you can set a variable using a VARIABLE > SET VALUE action.

                    Corey Milner
                    Creative Director, Indigo Rose Software

                    Comment

                    • meaningless
                      Forum Member
                      • May 2003
                      • 9

                      #11
                      Re: Toggle Switch

                      Ok it looks like we are getting nowhere fast so here is what I am trying to do and the code I am trying to do it with...

                      I have project that, when started, loads a directory of mp3's into a listbox and when the user double clicks on any of the mp3's they beging to play and when the song they clicked on is over it goes to the next song and it begins to play and so on and so forth until all the songs have played. This part works fine.

                      I also have a 2 buttons (on/off) that will allow the user to repeat (loop) one song over and over until they click on the off button and it will then play till the end of the song and stop. This part also works fine.

                      The problem with this is if I double click on a song and it begins to play and then moves on to the next song automatically when it's done there is no way that I can use the repeat (looping) feature I have on my buttons which makes sense if you think about it because the program can only do one thing at a time so what I need is "one button" that will stop the automatic playing of the next song in the list and repeat (loop) the currently playing song at the same time.

                      I also want this "one button" to be able to turn the repeat feature off if I click on it again while a song is looping.

                      The only code I can show you is the code for the automactic playing of the next song because this is all I have that works the way I want it to so far. Please note that this code is a modified version of some code that worm posted on here so all credit goes to him for this code.

                      This code is on the "On Song End" event of the mp3 player properties function.

                      %ListCount% = ListBoxObject[lstPlayList].GetProperty("Item Count")

                      %SelectedIndex% = Evaluate(%SelectedIndex% +1)

                      IF (%SelectedIndex% <> %ListCount%)

                      ListBoxObject[lstPlayList].Select(%SelectedIndex%)

                      %itemtext% = ListBoxObject[lstPlayList].GetItemText(%SelectedIndex%)

                      MP3.Load("%SrcDir%\mp3s\%ItemText%.mp3")

                      Application.Sleep ("1")

                      MP3.Play

                      END IF

                      Comment

                      • meaningless
                        Forum Member
                        • May 2003
                        • 9

                        #12
                        Re: Toggle Switch

                        Ok I did a search in the help file for toggle and it gave me an example which I used and it now uses one button for turning on/off the looping feature now all I have left to figure out is how to make it so it will also turn off the "on song end" event that I posted above at the same time...

                        Comment

                        • TJ_Tigger
                          Indigo Rose Customer
                          • Sep 2002
                          • 3159

                          #13
                          Re: Toggle Switch

                          Use the code the kpsmith provided to set the looping condition. You could do this with a text object as well. Here is a sample.

                          IF (%Loop% = OFF)
                          %Loop% = "ON"
                          MP3.SetRepeat (TRUE)
                          TextObject[Text1].SetText ("Repeat %Loop%")
                          ELSE
                          %Loop% = "OFF"
                          MP3.SetRepeat (FALSE)
                          TextObject[Text1].SetText ("Repeat %Loop%")
                          END IF

                          Straight forward to create a text Object toggle button

                          Then in the "On Song End" actions page do a check for the %Loop% variable to see if it is "ON" or "OFF". If it is on then do your script

                          IF (%Loop% = ON)
                          %ListCount% = ListBoxObject[lstPlayList].GetProperty("Item Count")
                          %SelectedIndex% = Evaluate(%SelectedIndex% +1)
                          IF (%SelectedIndex% <> %ListCount%)
                          ListBoxObject[lstPlayList].Select(%SelectedIndex%)
                          %itemtext% = ListBoxObject[lstPlayList].GetItemText(%SelectedIndex%)
                          MP3.Load("%SrcDir%\mp3s\%ItemText%.mp3")
                          Application.Sleep ("1")
                          MP3.Play
                          END IF
                          END IF

                          That is what I would do anyways.
                          TJ-Tigger
                          "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
                          "Draco dormiens nunquam titillandus."
                          Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

                          Comment

                          Working...
                          X