7 Replies Latest reply on Apr 20, 2011 7:44 AM by Ned Murphy

    Hello,

    TorsekarM29

      I

      am using flash actionscript2.0. I've made one flash photog

      allery using AS2.but I that

      code is suitable for AS3 only which include mouseevent.

      So,now I'm getting errors for the same as mouseevent couldn't be loaded.I'm giving that code here which is for AS3.

      Can anyone tell me which changes should I make to use it in AS2?

       

      stop();
      btn1.addEventListener(MouseEvent.CLICK,play1);
      function play1(event:MouseEvent):void{
      gotoAndStop ("fl1")
      }
      btn2.addEventListener(MouseEvent.CLICK,play2);
      function play2(event:MouseEvent):void{
      gotoAndStop ("fl2")
      }
      btn3.addEventListener(MouseEvent.CLICK,play3);
      function play3(event:MouseEvent):void{
      gotoAndStop ("fl3")
      }
      btn4.addEventListener(MouseEvent.CLICK,play4);
      function play4(event:MouseEvent):void{
      gotoAndStop ("fl4")
      }

        • 1. Re: Hello,
          dannyb89

          stop();

          btn1.onPress = function(){

               gotoAndPlay("fl1")

          }

           

          or

           

          stop();

          btn1.onRelease = function(){

               gotoAndPlay("fl1")

          }

           

          etc etc...

           

          Message was edited by: dannymarkbrooks

          • 2. Re: Hello,
            TorsekarM29 Level 1

            Hello sir,

                   Your code has worked. but still on clicking  all buttons,it is playing all images & not the perticular which we want.

                     Also, I want 2 ask one more question- is there any need to write mouseevent or like that inside that function()  ?

            • 3. Re: Hello,
              dannyb89 Level 1

              i think you may be able to do this:

               

              var mListener:Object = new Object();

               

              mListener.onMouseDown = function():Void

              {

                  add your function e.g. gotoAndStop("fl1")

              }

              • 4. Re: Hello,
                dannyb89 Level 1

                And i think it played all images becasue i said gotoAndPlay instead of gotoAndStop...sorry mate

                • 5. Re: Hello,
                  TorsekarM29 Level 1

                  stop();

                  var mListener:Object = new Object();
                  mListener.onMouseDown = function():Void

                  {

                      gotoAndStop("fl1")

                  }

                  var mListener:Object = new Object();
                  mListener.onMouseDown = function():Void

                  {

                      gotoAndStop("fl2")

                  }

                  var mListener:Object = new Object();
                  mListener.onMouseDown = function():Void

                  {

                      gotoAndStop("fl3")

                  }

                  var mListener:Object = new Object();
                  mListener.onMouseDown = function():Void

                  {

                      gotoAndStop("fl4")

                  }

                   

                  hello sir,

                         I've used it like this. but now its not showing anything.means it is showing only 1st img on clicking of all buttons.I want 2 ask u-whether it is necessary 2 create new object 4 each frame?  i.e.

                  var mListener:Object = new Object();

                  • 6. Re: Hello,
                    TorsekarM29 Level 1

                    stop();

                    btn1.onRelease = function(){

                         gotoAndStop("fl1");

                    }

                     

                    Hello sir,

                          I've used this code.It works only when we go serially btn1,btn2,btn3,btn4..If we go randomly,It doesn't work.

                    • 7. Re: Hello,
                      Ned Murphy Adobe Community Professional & MVP

                      The code below will be the proper way to code what you want your buttons to do.

                       

                      stop();

                       

                      btn1.onRelease = function(){

                           gotoAndPlay("fl1")

                      }

                       

                      btn2.onRelease = function(){

                           gotoAndPlay("fl2")

                      }

                       

                      btn3.onRelease = function(){

                           gotoAndPlay("fl3")

                      }

                       

                      btn4.onRelease = function(){

                           gotoAndPlay("fl4")

                      }

                       

                      If that is how you have it coded, then the problem will most likely be in how you implemented the buttons in the timeline. Can you show a screenshot and/or explain how you have the buttons planted in the timeline, how you name them, and where you assign the code?