8 Replies Latest reply on Jun 30, 2006 6:30 AM by kglad

    AS animated _alpha on a button problem

    Andra Veraart

      Hi there,

      I'm using the following code to animate the _alpha value of a button up and down:

      _root.fadeIn = function(){
      nav.tekst._alpha += 2;
      if (nav.tekst._alpha >= 100) {
      delete this.onEnterFrame;
      this.onEnterFrame = _root.fadeOut;
      }
      }

      _root.fadeOut = function(){
      nav.tekst._alpha -= 1;
      if (nav.tekst._alpha <= 50) {
      delete this.onEnterFrame;
      this.onEnterFrame = _root.fadeIn;
      }
      }

      this.onEnterFrame = _root.fadeOut;

      The button contains only one textfield. It's static text, so there shouldn't be any embeding issues, right? The opacity of the button seems to "jump" somewhere between the values 75 and 80. Almost as though it increments (or decreases) with 10 instead of 1 for one frame, and then goes on normally. Tracing the _alpha-value didn't reveal any such behaviour.

      Any ideas on what it could be, or how to possibly work arround it?
      I'd rather not animate the text in the button or something, because the button should only blink under certain conditions.
      Thanks in advance!

      Yours,
      Andra
        • 1. Re: AS animated _alpha on a button problem
          kglad Adobe Community Professional & MVP
          the code you showed should cause your movieclip's alpha to decrease to about 50 and then increase to about 100 and decrease again, ad infinitum.

          if your movieclip is doing anything else, it's because of some other code. and nav.tekst is a movieclip or button, correct?
          • 2. Re: AS animated _alpha on a button problem
            Andra Veraart Level 1
            nav is a movieclip on the _root.
            tekst is a button inside of nav.
            tekst only contains a static text-field.

            I can't think of any code influencing that button on a frame to frame basis. But I'll stare at it some more when I get back to work tomorrow.

            Yours,
            Andra
            • 3. Re: AS animated _alpha on a button problem
              See4th
              Andra,
              Try this code and see if you still have the same problem.

              Thanks,

              Jeff

              • 4. Re: AS animated _alpha on a button problem
                kglad Adobe Community Professional & MVP
                if there's no other code, your judgement about what you think the transparency is and the speed at which it's changing may be the problem. you could lower your 50 to 10 or so and increase your swfs fps so you can more easily judge what's happening.
                • 5. AS animated _alpha on a button problem
                  Andra Veraart Level 1
                  First of all, here's the full code for this (first) frame:


                  -----------------------------------------------------------------
                  this._lockroot = true;
                  stop();

                  tekstMC.tekstScrollerMC.enabled = false;

                  nav.vorig._visible = false;
                  nav.hoofd._visible = false;

                  nav.tekst.onRelease = function() {play()}
                  nav.adv.onRelease = function() {play()}

                  _root.fadeIn = function(){
                  nav.tekst._alpha += 1;
                  trace(nav.tekst._alpha);
                  if (nav.tekst._alpha >= 80) {
                  delete this.onEnterFrame;
                  this.onEnterFrame = _root.fadeOut;
                  }
                  }

                  _root.fadeOut = function(){
                  nav.tekst._alpha -= 1;
                  if (nav.tekst._alpha <= 79) {
                  delete this.onEnterFrame;
                  this.onEnterFrame = _root.fadeIn;
                  }
                  }

                  this.onEnterFrame = _root.fadeOut;

                  nav.adv._alpha = 30;

                  nav.tekst.enabled = true;
                  nav.adv.enabled = false;

                  -----------------------------------------------------------------


                  My movie's framerate is at 25 fps. With this range (79 to 80) and this increment (1 per frame), the change should be barely visible. Instead it looks like it's blinking between 70 and 80 (or something like that). It does so during the fadeOut AND fadeIn functions.
                  There is only one other movieclip that has it's own code attached to it, but none of it even refers to .nav, let alone .nav.tekst._alpha.

                  If anyone's interested, I've uploaded the .fla-file to http://www.multimediamatters.nl/breukhoven.zip. I'm talking about the code on the first frame in the actions-layer. The code on frame 19 will be updated as soon as I find a solution for frame one. On that frame, I want to do the same thing on a different button.

                  By the way, See4th, you can see on frame 19 that I started off with a single function like you suggested. I only switched to 2 functions in the hopes of finding a solution for the blinking problem, which also occurd with this function. Thanks for the suggestion though!

                  I hope I haven't left anything out. Thanks again!

                  Yours,
                  Andra

                  • 6. Re: AS animated _alpha on a button problem
                    kglad Adobe Community Professional & MVP
                    that's an anti-alias issue. when you change from an _alpha of 78 to 79 there's a change in the anti-aliasing that's much more dramatic than the _alpha change.

                    to remedy use anything other than anti-alias for readability.
                    • 7. Re: AS animated _alpha on a button problem
                      Andra Veraart Level 1
                      quote:

                      Originally posted by: kglad
                      that's an anti-alias issue. when you change from an _alpha of 78 to 79 there's a change in the anti-aliasing that's much more dramatic than the _alpha change.

                      to remedy use anything other than anti-alias for readability.


                      That's it! kglad, thanks for your advice!

                      Just wanted to add that any form of custom anti-aliasing didn't seem to work either. Even with both values set to zero.
                      Not using "anti-alias for readability" thins the font out a bit, but I'm using a bold version of the font instead and it's looking well enough.

                      Thanks again!

                      Yours,
                      Andra
                      • 8. Re: AS animated _alpha on a button problem
                        kglad Adobe Community Professional & MVP
                        you're welcome.