7 Replies Latest reply on Aug 9, 2006 8:57 AM by frashjiveturkey

    Custom Button in Director MX 2004

    3Dimka
      I need a 3 state button with my custom bitmaps, but I can't get it done ib Director MX.
      Is there ready non-Flash solution?

      Thanx
      3Dimka ;)
        • 1. Re: Custom Buttons im Director MX 2004
          Level 7
          I'm not sure of your question, so apologies if I'm off the mark.
          Generally you'd produce 3 separate graphics for different button states,
          drag the default one to the stage and apply a behavior providing
          rollOver and mouseDown graphic changes
          • 2. Re: Custom Buttons im Director MX 2004
            3Dimka Level 1
            Thanks for fast reply, Sean.

            I was actually going to do so, but I needed lots of buttons like that. Is there a way I can use one script for all buttons? I didn't figure out how to assign custom properties to an image in which I could store names of additional bitmaps and access them from just one script. I wouldn't like to duplicate same script all over...

            3Dimka ;)

            quote:

            Originally posted by: Newsgroup User
            I'm not sure of your question, so apologies if I'm off the mark.
            Generally you'd produce 3 separate graphics for different button states,
            drag the default one to the stage and apply a behavior providing
            rollOver and mouseDown graphic changes



            • 3. Re: Custom Buttons im Director MX 2004
              Shellgrip
              3Dimka, it's difficult to advise precisely without knowing more about the structure of your movie but perhaps this will help.

              I've developed a few applications that link sprites and cast members through a relationship to the _movie.frame property. So, in your case, if you need a sprite to have three states, those three cast members would be located within the cast in a direct equation with the frame number in the score. If you're using member(10), member(11), and member(12) at frame 10, then you use member(20), member(21) and member(22) at frame 20 and so on. How successful or pratical this is depends on your movie but it does mean you can use the same script for all buttons.

              An alternative would be to vary the sprite number to access different cast members (or casts!), again allowing a single script to work for all situations. So sprite(1), uses member(1), member(2) and member(3), sprite(2) uses member(4), member(5) and member(6) and so on. The exact math relationship would be up to you.

              If you've got a lot of buttons and scenes you could combine the two ideas so that you relate your sprites to the members of a cast and also change the cast used depending upon score position.

              I'm sure there are other, better, ideas but this might help.

              Jon
              • 4. Re: Custom Buttons im Director MX 2004
                3Dimka Level 1
                Thanks Jon, I got your idea. But I prefer object oriented approach so using direct indexes is not reliable and safe. I think some global object like "ButtonManager" which stores settings of all buttons would be a solution, though it's overhelming for a such primitive thing as a button is...

                Another problem is that I'm using a 3D control and it is always on top, overlaping any non-3D control. But that's another story...

                3Dimka ;)


                quote:

                Originally posted by: Shellgrip
                3Dimka, it's difficult to advise precisely without knowing more about the structure of your movie but perhaps this will help.

                I've developed a few applications that link sprites and cast members through a relationship to the _movie.frame property. So, in your case, if you need a sprite to have three states, those three cast members would be located within the cast in a direct equation with the frame number in the score. If you're using member(10), member(11), and member(12) at frame 10, then you use member(20), member(21) and member(22) at frame 20 and so on. How successful or pratical this is depends on your movie but it does mean you can use the same script for all buttons.

                An alternative would be to vary the sprite number to access different cast members (or casts!), again allowing a single script to work for all situations. So sprite(1), uses member(1), member(2) and member(3), sprite(2) uses member(4), member(5) and member(6) and so on. The exact math relationship would be up to you.

                If you've got a lot of buttons and scenes you could combine the two ideas so that you relate your sprites to the members of a cast and also change the cast used depending upon score position.

                I'm sure there are other, better, ideas but this might help.

                Jon


                • 5. Custom Button in Director MX 2004
                  frashjiveturkey
                  if you name your custom graphics in a similar way you can write a behavior that will sort things out for you.
                  ie. the name of a set of buttons in the cast could be. "mybutton normal" "mybutton over" and "mybutton down".

                  the behavior can take the first word from the member of the sprite it's applied to and add the rest accordingly. So the behavior would be as follows.

                  on mouseenter me
                  nametochange=sprite(me.spritenum).member.name.word[1]
                  sprite(me.spritenum).member=member(nametochange & " over")
                  end
                  on mouseleave me
                  nametochange=sprite(me.spritenum).member.name.word[1]
                  sprite(me.spritenum).member=member(nametochange & " normal")
                  end
                  on mouseup me
                  nametochange=sprite(me.spritenum).member.name.word[1]
                  sprite(me.spritenum).member=member(nametochange & " normal")
                  end
                  on mouseupoutside me
                  nametochange=sprite(me.spritenum).member.name.word[1]
                  sprite(me.spritenum).member=member(nametochange & " normal")
                  end
                  on mousedown me
                  nametochange=sprite(me.spritenum).member.name.word[1]
                  sprite(me.spritenum).member=member(nametochange & " down")
                  end


                  The variable 'nametochange' picks the first word from the member of whichever sprite it's attached to then depending on the mouse event, will switch the member around. This should be flexible enough as long as the naming structure of the buttons is consistant ie. one word then a space then "over", "down" or "normal".

                  The other alternative is to make your buttons in flash as individual swf's and import them into the cast. Then apply only the actual button's action in director ie. "go frame 50" or whatever.

                  Hope this helps.

                  Deryck

                  http://thecooker.net
                  • 6. Re: Custom Button in Director MX 2004
                    3Dimka Level 1
                    Thanks so much, Deryck

                    This looks like a decent workaround. I'll give it a try, however I'm still confused how to handle individual onMouseUp events. Should it be a 2nd behavior or should each button have it's onw onMouseUp behavior script with similar code?:

                    on mouseup me
                    --same code for all buttons
                    nametochange=sprite(me.spritenum).member.name.word[1]
                    sprite(me.spritenum).member=member(nametochange & " normal")
                    -- do something special
                    end



                    Thanks!
                    3Dimka ;)


                    quote:

                    Originally posted by: frashjiveturkey
                    if you name your custom graphics in a similar way you can write a behavior that will sort things out for you.
                    ie. the name of a set of buttons in the cast could be. "mybutton normal" "mybutton over" and "mybutton down".

                    the behavior can take the first word from the member of the sprite it's applied to and add the rest accordingly. So the behavior would be as follows.

                    on mouseenter me
                    nametochange=sprite(me.spritenum).member.name.word[1]
                    sprite(me.spritenum).member=member(nametochange & " over")
                    end
                    on mouseleave me
                    nametochange=sprite(me.spritenum).member.name.word[1]
                    sprite(me.spritenum).member=member(nametochange & " normal")
                    end
                    on mouseup me
                    nametochange=sprite(me.spritenum).member.name.word[1]
                    sprite(me.spritenum).member=member(nametochange & " normal")
                    end
                    on mouseupoutside me
                    nametochange=sprite(me.spritenum).member.name.word[1]
                    sprite(me.spritenum).member=member(nametochange & " normal")
                    end
                    on mousedown me
                    nametochange=sprite(me.spritenum).member.name.word[1]
                    sprite(me.spritenum).member=member(nametochange & " down")
                    end


                    The variable 'nametochange' picks the first word from the member of whichever sprite it's attached to then depending on the mouse event, will switch the member around. This should be flexible enough as long as the naming structure of the buttons is consistant ie. one word then a space then "over", "down" or "normal".

                    The other alternative is to make your buttons in flash as individual swf's and import them into the cast. Then apply only the actual button's action in director ie. "go frame 50" or whatever.

                    Hope this helps.

                    Deryck

                    http://thecooker.net


                    • 7. Re: Custom Button in Director MX 2004
                      frashjiveturkey Level 1
                      Oops, made a slight oversight.
                      You could have one behavior to handle all the mouseenter and mouseleave etc. and a separate one to deal with the actual action of the button.

                      This would make the rollover behavior...

                      on mouseenter me
                      nametochange=sprite(me.spritenum).member.name.word[1]
                      sprite(me.spritenum).member=member(nametochange & " over")
                      end
                      on mouseleave me
                      nametochange=sprite(me.spritenum).member.name.word[1]
                      sprite(me.spritenum).member=member(nametochange & " normal")
                      end
                      on mouseupoutside me
                      nametochange=sprite(me.spritenum).member.name.word[1]
                      sprite(me.spritenum).member=member(nametochange & " normal")
                      end
                      on mousedown me
                      nametochange=sprite(me.spritenum).member.name.word[1]
                      sprite(me.spritenum).member=member(nametochange & " down")
                      end

                      This will deal with when a user interacts with the button without actually 'using' it.

                      Then make separate behaviors for each different mouseup to deal with the actual action, like..
                      on mouseup me
                      nametochange=sprite(me.spritenum).member.name.word[1]
                      sprite(me.spritenum).member=member(nametochange & " normal")

                      go frame 100
                      end

                      Apply the rollover behavior to all the buttons, then add the mouseup behaviors to buttons depending on what you want them to do.

                      I've removed the on mouseup handler from the rollover script to avoid any possible conflict between 2 mouseup events for the same sprite at the same time.

                      Director doesn't use the nested movieclip structure that Flash does so this sort of stuff needs to be scripted.

                      Also, Director doesn't change the mouse cursor for you. Which can be a good or bad thing depending on your point of view.
                      If you want to change the mouse to a pointing finger on rollover etc. you'll need to add
                      cursor 280 -- for the pointing finger on mouseenter
                      and
                      cursor -1 -- to swap back to the arrow on mouseleave/mouseupoutside etc.


                      Deryck
                      http://thecooker.net