5 Replies Latest reply on Mar 23, 2011 12:01 PM by Trucker Chris

    Some Buttons don't work as they are supposed to

    Trucker Chris Level 1

      Hey guys,

       

      I use Flash only four times a year and I just updated CS4 to CS5. I opened a AS 3.0 fla file (created in Flash CS4) in Flash CS5. Everything looked fine and all the Buttons worked perfectly.

       

      Now in the Submenu I added two more Buttons using the same script as for the others, published it and no errors in the compiler were shown.

       

      Then I tested the Buttons and some Buttons didn't get me to the frame, where they were supposed to go. I think the Buttons didn't work at all, but I am not sure. I checked the Project, but couldn't find any diferences between the working and not working Buttons. I tried to reproduce the error, but couldn't make it 100%, because some Buttons stop working the second time I click on them. I have no idea where to locate an error???

       

      Any Help would be really appreciated!!!

       

      Here is some of the code:

       

      stop();

       

      R_SB_Werbung.addEventListener(MouseEvent.CLICK,gotoWerbung);
      function gotoWerbung(event:MouseEvent):void
      {SoundMixer.stopAll();gotoAndStop(10);

        R_SB_W_KuFiFe.addEventListener(MouseEvent.CLICK,gotoKuFiFe);
        function gotoKuFiFe(event:MouseEvent):void
        {SoundMixer.stopAll();gotoAndStop(11);
         KuFiFewatch.addEventListener(MouseEvent.CLICK,gotoKuFiFewatch);
         KuFiFewatchButton.addEventListener(MouseEvent.CLICK,gotoKuFiFewatch);
         function gotoKuFiFewatch(event:MouseEvent):void
         {gotoAndStop(12);}
        }

      }

        • 1. Re: Some Buttons don't work as they are supposed to
          kglad-zqbLf4 Level 3

          use the trace() function to debug your code.  for example, you can easily determine if a function is being called by adding a trace("something") to that function.

          1 person found this helpful
          • 2. Re: Some Buttons don't work as they are supposed to
            Trucker Chris Level 1

            Thanks kglad,

             

            I am not sure if I did what you told me to do. For every event listener I added a trace() function, which reported, if the event listener got called or not, but still I am not able to find the error, because if the Button doesn't work, the event listener doesn't get called. I think it could have something to do with the Buttons, but I copied some working Buttons from one keyframe to another one, but that still did't solve the problem. They do have the same instance, so I don't understand, why some Buttons work and others don't ; (

             

            Any further ideas???

            • 3. Re: Some Buttons don't work as they are supposed to
              kglad-zqbLf4 Level 3

              if your listener function isn't called, you have an incorrect reference to the event dispatcher (your button).  there are many ways that can happen with as3.

               

              the only certain way to fix the problem is to go to the first keyframe that contains your problematic button and assign the same instance name as that used in your code.  remove all keyframes after that first keyframe.  test your listener code.

              • 4. Re: Some Buttons don't work as they are supposed to
                Trucker Chris Level 1

                Dear kglad,

                 

                thank you very much for your help!!!

                It seems that I have a hard time understanding your hints even though they might be the solution to my problem.

                 

                I only have one Event Listener per Button.

                There is only one Instance for each Button, but these Buttons are pasted in different frames in the timeline.

                 

                I used the swap... Button to make sure every copy of the instance has the same name.

                 

                All Buttons work at the beginning, but as soon one or the other button has been clicked, some event Listeners don't seem to react anymore.

                 

                Would be great, if you have a step by step description, because I am a real newbie to Flash.

                 

                Thanks in advance.

                • 5. Re: Some Buttons don't work as they are supposed to
                  Trucker Chris Level 1

                  Problem solved. Thank you for your help anyways kglad!

                   

                  The script was fine. Something was wrong with the Buttons. I created a new Layer, removed all the old Buttons except the ones from Frame 1. Copied and pasted them into the other frames and everything worked.

                   

                  Workaround of half an hour is sometimes better than looking eight hours for the error beeing frustrated.