5 Replies Latest reply on Apr 22, 2006 1:47 PM by TimSymons

    Roll Over Buttons

    EBDelos
      Hey Everyone!

      i have type buttons that are set at 50% alpha, and i want it so when the mouse rolls over it, its at 100%

      The script im using checked out to not have problems, but when i preview it, its not working at all! the script im using is below...

      can anyone help me on this?

      Thanxs!
      -Liz
        • 1. Re: Roll Over Buttons
          TimSymons Level 1
          When you say you have "...type buttons..." do you mean that they are text or that your elements or of the type "Button" versus "MovieClips"? If they are text then besure to embed the fonts, otherwise the _alpha part won't work on the text.

          I tried your code by drawing a rectangle and turing it into a type Button named "graphic_design". It worked when I ran it, the only thing was that it stayed at alpha=100 until I rolled over it once. To get it to start in the correct state you will have to either set the alpha to 50% during authoring or add this line of code:

          graphic_design._alpha = 50;

          before your onRollOver and onRollOut functions.

          Tim
          • 2. Re: Roll Over Buttons
            Level 7
            EBTurner,

            > i have type buttons that are set at 50% alpha, and i
            > want it so when the mouse rolls over it, its at 100%

            > The script im using checked out to not have problems,
            > but when i preview it, its not working at all!

            Actually, the script you're using has problem.

            > graphic_design.onRollOver = function() {
            > graphic_design._alpha=100
            > }

            You're very close, here. Let's think through this from the point of
            view of the button. You're assigning a function to the Button.onRollOver
            event of a given Button instance. For this reason, everything inside the
            function is scoped to graphic_design; that is, the point of view is
            graphic_design's point of view.

            Inside the function, you're telling graphic_design to look for an object
            with the instance name graphic_design and set its Button._alpha property to
            100. But we're *in* graphic_design! There isn't a second, nested copy of
            the same button inside itself. So we need a way to refer to graphic_design
            itself, from inside this function. The answer is the global "this"
            property, which always points to the object or timeline it's in.

            graphic_design.onRollOver = function() {
            graphic_design._alpha=100;
            }


            David
            stiller (at) quip (dot) net
            Dev essays: http://www.quip.net/blog/
            "Luck is the residue of good design."


            • 3. Re: Roll Over Buttons
              Level 7
              I just read Tim's reply to your question, and I think he's on the right
              track, while I missed it completely. For sake of clarity, I'd like to
              correct my own reply.

              What I said was correct in principle, but not entirely in fact. My
              suggestion to use "this" remains a good suggestion, but your original code
              still works just fine as far as changing the Button._alpha property of a
              button. The reason for this due to the way ActionScript identifies objects
              as it looks for them. In your example -- and I'm honestly ashamed that I
              didn't address this -- the graphic_design object mentioned inside the
              function would, of course, not be there. When not found, the compiler will
              look "up the chain," so to speak, to see if graphic_design *can8 be found.
              And it can, of course, since it's available on the very next link of that
              chain.

              Thanks, Tim!


              David
              stiller (at) quip (dot) net
              Dev essays: http://www.quip.net/blog/
              "Luck is the residue of good design."


              • 4. Re: Roll Over Buttons
                EBDelos Level 1
                haha, thanxs David

                Tim- yes i the buttons are actual text. and i do already have the alpha set at 50%.

                So im going to assume the only problem im having is the embeded text.... and this is going to sound really silly... but how do you embed text?!

                Thanxs guys!!!
                • 5. Re: Roll Over Buttons
                  TimSymons Level 1
                  You can embed text 2 ways. One is to inlcude the font in the Library and set it to export when you publish the file. This allow syou to specify a name for your font and use it throughout your program. However, I don't like that method, but it will work. The other method I use it to create the dynamic textfield on the stage, type something in the font and style I like, or multiple styles once I have selected the "render as html" option icon in the parameters box. Then you will need to click on the "Embed..." button in the parameters box. This will only appear if your text is set to Dynamic or Input. Select the characters you want to emed and your done.

                  I also use this method at the beginning of my movies and create a dynamic textfield off stage and put each font and font style that I will use throughout my program. Then when I create textfields using ActionScript and set the embedFonts property to true my fonts will render. This also helps a lot with using StyleSheets and setting fonts from them as well.

                  Lastly, this is not the only nor the best way to embed fonts but it will get you started.

                  Tim