3 Replies Latest reply on Dec 22, 2006 11:18 PM by FasterPastor

    How hard can a radio button be?

    caschen
      I have taken a radio button out of the library (components), given it the name "Rad" in the cast, and put it on the stage.
      I have created a button from the same library palette, and given it this behavior:

      on mouseUp()
      if member ("Rad"). hilite then go to Frame (5)
      end
      and nothing happens? Could someone please tell me what I am missing?
        • 1. Re: How hard can a radio button be?
          Level 7
          The only radio button that has the hilite property may be the primitive
          one in the tool palette (command-7) window.

          Buttons made from bitmap members may lack the hilite prop.
          • 2. How hard can a radio button be?
            FasterPastor Level 1
            Caschen

            What version of Director are you using? I am using 8.5.1.

            In my version, there is no radio button in the Library. As mentioned, there is a "primitive" radio button creator in the Tool Palette. Note that there is a /behavior/ in the Library called "Radio Button GROUP" -- that simply allows you to make it so only one button in your group can be selected at a time. That behavior can be dragged into a cast, and then dragged from there onto each sprite that is tied to a radio button cast member created from the Tool Palette.

            I had never messed with radio buttons before, but just now I created a working sample movie that I will describe below. There is obviously more than one way to do this, but everything works just fine in the way I did it.

            When using the Radio Button option in the Tool Palette (the button "creator"), one can either (1) use it once and then copy and paste the resulting cast member, or (2) use it over and over to get multiple cast members. Each radio button in a group needs its own cast member. The /behavior/ I mentioned (from the Library) need not exist in the cast but once.

            Each radio button /cast member/ can then be dragged into the score, so each gets its own sprite / sprite channel in the score. The behavior described above should be applied to the /sprites/. Add unique text to each member by clicking into each one on the stage. A unique name for each cast member is helpful. In the behavior script below, I used the cast member name of each button to guide which marker in the score the user would be navigated to. Obviously the names of the markers must match the names of the radio button cast members for that to work.

            The following behavior script can then be created, and applied to each one of the SPRITES, from which we can access the hilite property of a radio button's MEMBER:

            on mouseUp me
            spr = me.spriteNum
            if sprite(spr).member.hilite then
            alert("Member(" & QUOTE & sprite(spr).member.name & QUOTE & ") in sprite channel (" & spr & ") was highlighted!")
            go to frame(sprite(spr).member.name)
            end if
            end

            If this does not help you, I can attach the sample movie I created, in which the above technique works perfectly.
            • 3. Re: How hard can a radio button be?
              FasterPastor Level 1
              And... looking again at your original post, I see you didn't want the user to jump to the frame/marker at the very moment they clicked the radio button, but rather you wanted to wait until they clicked a push button after making their selection, before being navigated away.

              OK. To do that, consider all that I wrote above, and add to it, this:

              Make another set of radio button cast members, and name them accordingly, for a second group. Drag and drop them onto the score/stage, and then drag and drop the "group" behavior onto the sprites, so only one can be selected at a time. Each time you drag the "GROUP" behavior, you must supply a matching name for all buttons in the given group.

              This time around, do /not/ apply the "mouseUp" script (in the above post) to each one. Instead, create a push button member and sprite, and add the following behavior script to the sprite for the push button. Note: for this example, the sprites for the second radio button group... are in channels 8, 9, and 10.

              on mouseUp me
              -- cycle through the sprite channels containing the radio buttons of group02
              repeat with i = 8 to 10
              if sprite(i).member.hilite then
              alert(sprite(i).member.name & " was highlighted!")
              go to frame(sprite(i).member.name)
              end if
              end repeat
              end