8 Replies Latest reply on Jul 7, 2008 10:00 AM by kglad

    problem with as1+2


      I've got a problem with Flash CS3 and Actionscript 2.
      I want to create an animation of a movieclip. This animation should start with the click on a button. A repeated click on this button should stop the animation. So I created a button and a movieclip and declarated them. Additionally I defined the IDs of all this elements. But the problem is, that nothing happens if I click the button.

      But at first I should show my code:

      var myButton_btn:Button;
      var myMC:MovieClip;
      var isHighlighted:Boolean = false;

      myButton_btn.onRelease = function () {
      if(isHighlighted) {
      myMC.gotoAndStop (1);
      isHighlighted = false;
      else {

      The boolean shows if the animation is already running.

      The button, the movieclip and the code are located in different layers, but they all are under the root element.

      The debugger shows, that on a click event the function on myButton isn't called.

      May someone have an idea what's my fault?

      Thanks and best regards,
        • 1. Re: problem with as1+2
          kglad Adobe Community Professional & MVP
          you have mismatched curly brackets so you should see a compiler error.
          • 2. Re: problem with as1+2
            01900 Level 1
            sorry it was my fault
            the curly brackets are a typing error in the message and when I run the file I see no compiler error but also no animation...
            best regards,
            • 3. Re: problem with as1+2
              kglad Adobe Community Professional & MVP
              copy and paste your code using the attach code option in this forum.
              • 4. problem with as1+2
                01900 Level 1
                all right, the completelly code is attached
                • 5. problem with as1+2
                  __smileHare Level 1

                  btn.onRelease = function()

                  Sorry I missed.
                  You have to give a whole path of the variables.
                  Thanks to next floor.
                  • 6. Re: problem with as1+2
                    kglad Adobe Community Professional & MVP
                    that code probably isn't going to do what you want it to do.

                    if you want each button to play and stop its associated movieclip, you probably want to use different boolean for each button. so, use this.isHighlighted instead of isHighlighted in your onRelease handlers.

                    but if none of your buttons are calling their onRelease handlers, you have a more basic problem: the instance path/names of your buttons don't match the names in your script.
                    • 7. Re: problem with as1+2
                      01900 Level 1
                      Hi again,

                      I think I figured out the problem. For testing I created a new scene. There I created a folder and a layer in this folder. All actionscript code is located in a root layer at the beginning of the scene.
                      The hierarchy looks like this:

                      -> code_layer
                      -> test_layer
                      -> BUTTON_FOLDER
                      -> -> button_layer

                      If the button is located in the "test_layer" all works fine. But if I move the button to the button_layer, the script isn't working.

                      Now my question is, how should the path to the button look like?
                      I tried some combinations ( _root.BUTTON_FOLDER.button_layer.myButto n and so on) but nothing works.

                      Thanks again for help,
                      best regards,
                      • 8. Re: problem with as1+2
                        kglad Adobe Community Professional & MVP
                        layers and folders in your layers are irrelevant. no layers are in your published swf.

                        layers are used by flash to assign depths to stage objects and can be used to determine code execution order.

                        so, the path to your button should be:


                        and it doesn't matter which layer contains your button. only that it has the name property that matches the name used in your actionscript.