7 Replies Latest reply on Jul 13, 2008 7:57 PM by kglad

    If/else

    Christopher Barnard
      I have an if/else statement here that when it comes off the 50th frame, a button is supposed to become fully opaque. This isn't working:

      if (glam_mc._currentframe == 50 ){

      glam_mc.next_btn._alpha = 25;

      }else if (glam_mc._currentframe <= 49){

      glam_mc.next_btn._alpha = 100;

      }

      Can anybody point me in the right direction? I thought this should work?

      Thanks in advance...!
        • 1. Re: If/else
          kglad Adobe Community Professional & MVP
          what do you mean by "..when it comes off the 50th frame.."?

          when that code executes you're checking if glam_mc is at its 50th frame or less than its 50th frame.
          • 2. Re: If/else
            Christopher Barnard Level 1
            Hi Kglad,

            My code sends me to the 50th frame of the timeline, that may sound strange but I'm adding multiple galleries and they need to be on separate frames. It's easier to add new galleries to 51,52 etc in the future.

            At the last frame 50th I have a back button and forward button - the forward button needs to be set to alpha 25 if the user presses the back button to go backwards chronologically through the galleries I'd like the forward button to become active with alpha 100.

            My code doesn't do it. I hope this makes sense!

            Chris

            • 3. Re: If/else
              kglad Adobe Community Professional & MVP
              your code will work but it needs to execute each time glam_mc changes frames.
              • 4. Re: If/else
                Christopher Barnard Level 1
                So rather than copying and pasting the code on each frame, I need to create some code that will tell flash to listen to the whole timeline to detect when it's any frame last than 50.

                Just to make the point that this would be easy if it was just the arrow buttons, because I could have some code on the 50th and 49th thread to handle the opacity. Unfortuanately I have a menu as well so my code must detect when it jumps to any other frame other 50.

                So my challenge is how to make flash listen to the whole timeline - is that on the right tracks?

                Chris
                • 5. Re: If/else
                  kglad Adobe Community Professional & MVP
                  i can't say because i don't know how your swf is set-up. but you need to do something to detect when glam_mc changes frames. the least efficient way (but one that always works) is to use an onEnterFrame loop to repeatedly check the _currentframe of glam_mc.
                  • 6. Re: If/else
                    Christopher Barnard Level 1
                    Ah yes of course...

                    this.glam_mc.onEnterFrame = function () {
                    if (glam_mc._currentframe == 51 )
                    {trace ("last frame");
                    glam_mc.next_btn._alpha = 25;
                    }else if (glam_mc._currentframe <= 50){
                    glam_mc.next_btn._alpha = 100;
                    }

                    Thanks for the hints this worked, I do not have the clue about the memory efficiency or otherwise of these looping statements - but I'm happy that this does the trick.

                    Kind regards

                    Chris
                    • 7. Re: If/else
                      kglad Adobe Community Professional & MVP
                      you're welcome.

                      if there's a time when you no longer need to check glam_mc's _currentframe, you should execute a:

                      delete glam_mc.onEnterFrame;