8 Replies Latest reply on Jan 24, 2009 10:13 AM by kglad

    Same Code not doing Same thing

    TheInmate
      Hello,

      Using the actionscript 2 below:

      This first button stops the main timeline, everything works fine. The other three do not. I have checked and rechecked my instance names, etc. I can't find any difference in my code anywhere and after of couple of hours I'm at a loss at why this won't work. All the buttons are own their own layers. Each button is coded exactly the same. Any ideas?

      Thanks.
        • 1. Re: Same Code not doing Same thing
          kglad Adobe Community Professional & MVP
          are some buttons movieclip buttons?
          • 2. Re: Same Code not doing Same thing
            TheInmate Level 1
            Thanks for your reply. No, these are all buttons, not movieclips, although I do have a movieclip inside each button for the overstate (button fades to 50% opacity), but this has been done exactly the same way on each button. I added a different button (not at all like the others), but with a very similar code and it works fine. I've tried changing the order of the code, renaming the instances, but the first one always works, the last three do not. Here's the code for the new one that works:

            • 3. Re: Same Code not doing Same thing
              TheInmate Level 1
              I figured out something, but not sure what it means. The second button that does work, will not work if I move it out of the first frame of the main timeline say to frame 10. All my other buttons, except btn_1_btn start in different frames other than 1. My actionscript is on frame 1 in an actionscript layer. Anyone know why this would make a difference and have any idea what it means? I need these buttons where they are as they are also serving as images that are cycling through a sequence.
              • 4. Re: Same Code not doing Same thing
                kglad Adobe Community Professional & MVP
                are all the buttons visible when your code executes? ie, they all exist?
                • 5. Re: Same Code not doing Same thing
                  TheInmate Level 1
                  I figured out a solution which I'll go into in a moment. I'm not sure if I understand your question. All the buttons have been created and sit on the main timeline at different places (frames 1, 100, 200, etc). i.e. I am not creating buttons dynamically or on the fly.

                  What I finally did was simply move an instance of each button that was not on frame one to frame one on the main timeline, set the alpha to 0 so it didn't mess up my design and everything works. Not a great solution, but I couldn't get anything else to work.

                  Does this mean since my actionscript is on frame one, that anything I need it to act upon, must exist at frame one when the file loads? I'm not a FLASH expert by any means, but I don't ever remember having a problem like this before.
                  • 6. Re: Same Code not doing Same thing
                    kglad Adobe Community Professional & MVP
                    yes. you can't reference an object with actionscript before the object exists and expect the code containing the reference to work as you intend.
                    • 7. Re: Same Code not doing Same thing
                      TheInmate Level 1
                      I see. So, I suppose I could have also solved this by adding the actionscript on the same frame number where I added the new buttons? Just seems strange to me. I thought you were supposed to be able to keep all your actionscript in one place. I suppose if I wasn't such a novice at this there are much better ways to code this and that would be both possible and more desirable. . . .

                      Anyway, thanks for your help. I appreciate it.
                      • 8. Re: Same Code not doing Same thing
                        kglad Adobe Community Professional & MVP
                        you should keep all your actionscript in one place. and yes, with limited experience you have limited ways to deal with problems that you need to solve.