4 Replies Latest reply on Feb 11, 2010 3:45 AM by Single_Ton

    gotoAndStop(1) or gotoAndStop(2) not working

    Single_Ton

      Hi all

      i am loading external SWF and trying to Control it using a controlpanel,

      I am facing one issue on that, that is - When i sPress the knob i use gotoAndStop(frameNum), It works good when the Frame is not 1 or 2.

       

      If the frame count is 1 or 2 it is not getting stopped instead of that its getting played. there is no code in the Loaded clip.

       

       

      Total Script content  : File is also attached with this

       

       

       

      mouseListener = new Object();
      this.onEnterFrame = setCurrentPosition;

      //When pressing the knob, Start dragging

      knob_mc.onPress = function()
      {
          isKnobDrag = true;
          startDrag(this,false, progBar_mc._x, progBar_mc._y, (progBar_mc._x + progBar_mc._width), progBar_mc._y);
          Mouse.addListener(mouseListener);
      }

      //Release the drag event.
      knob_mc.onRelease = knob_mc.onReleaseOutside = function()
      {
              isKnobDrag = false;
          Mouse.removeListener(mouseListener);
      }

      //This will update the KnobPosition and Clipo Position.
      function setCurrentPosition()
      {
          if(isKnobDrag)
          {
              toalDur = loader_mc._totalframes;
              var bounds = progBar_mc.getBounds(_root);
              var frames = ((knob_mc._x - bounds.xMin) / progBar_mc._width) * toalDur;
              frames = Math.round(frames);
              frames = frames <= 0 ? 1 : frames;
              loader_mc.gotoAndStop(frames);
              frame_txt.text = frames;
          }
          else
          {
              knob_mc._x = progBar_mc._x + (loader_mc._currentframe * progBar_mc._width / loader_mc._totalframes)
              frame_txt.text = loader_mc._currentframe;
          }
         
      }
      loader_mc.loadMovie("Blank.swf");
      updateAfterEvent();


        • 1. Re: gotoAndStop(1) or gotoAndStop(2) not working
          kglad Adobe Community Professional & MVP

          if you're already on frame n, and you execute gotoAndStop(n), the playhead will remain fixed and not re-enter frame n.

          • 2. Re: gotoAndStop(1) or gotoAndStop(2) not working
            Single_Ton Level 1

            Thank you so much KGLAD,

             

            my Problem is :

             

            When i drag the Knob towards the Left most end, it automaticaly getting played, Actually it should stop there.....

            I am using gotoAndStop(frameNumber) to go and stop over there when i Drag the knob. The loaded SWF file is a Simple Tween animation (For testing)

             

            So there mightnot be any problem within this code. its not working as i expected.

             

            Help me to find out what i am doing wrong.

            • 3. Re: gotoAndStop(1) or gotoAndStop(2) not working
              kglad Adobe Community Professional & MVP

              first, you can simplify your code.  second, you should use the trace() function to see if your setting frames and knob_mc._x to what you want.

               


              //When pressing the knob, Start dragging
              knob_mc.onPress = function() {
                  startDrag(this, false, progBar_mc._x, progBar_mc._y, (progBar_mc._x+progBar_mc._width), progBar_mc._y);
                  this.onEnterFrame = setCurrentPosition;
              };
              //Release the drag event.
              knob_mc.onRelease = knob_mc.onReleaseOutside=function () {
                  knob_mc._x = progBar_mc._x+(loader_mc._currentframe*progBar_mc._width/loader_mc._totalframes);
                  frame_txt.text = loader_mc._currentframe;
                  delete this.onEnterFrame;
              };
              //This will update the KnobPosition and Clipo Position.
              function setCurrentPosition() {
                  toalDur = loader_mc._totalframes;
                  var bounds = progBar_mc.getBounds(_root);
                  var frames = ((knob_mc._x-bounds.xMin)/progBar_mc._width)*toalDur;
                  frames = Math.round(frames);
                  frames = frames<=0 ? 1 : frames;
                  loader_mc.gotoAndStop(frames);
                  frame_txt.text = frames;
              }
              loader_mc.loadMovie("Blank.swf");

              • 4. Re: gotoAndStop(1) or gotoAndStop(2) not working
                Single_Ton Level 1

                Thank you so much k-glad, Sorry for the delayed reply

                In next few hours i will reach home, I will test this over there.. But it seems that the code will not show the progress of the Current Clip.

                When animation is runnning the Knob will automaticaly move according to the Frame position....

                 

                i will test it and let u know the resuslt in few hours