3 Replies Latest reply on Jul 2, 2009 8:08 PM by kglad

    Could anyone help me out here regarding frame rate?

    whcodenza

      Hi, everyone,I need help with a dynamic frame rate issue,

       

      I have created this spinning diamond flash with a dynamic frame rate controlled by the mouse cursor.

       

      it spins from the right to the left if the cursor is at the left side of the diamond and vice verse, and also the further away the cursor is from the middle of the diamond, the faster it spins.

       

      it works perfectly awesome in Firefox and by itself, but when it's in IE, the cursor loses control of frame rate, so it spins at the highest frame rate regardless where the cursor is at.

       

      I used nextFrame(), prevFrame() to do the winding and rewinding job, and frame rate gets changed in ENTER_FRAME.

       

      I've heard some say that IE ignores frame rate per frame? is it true? if so, how do I fix it?

       

      Could anyone please help me out with this issue?it only happens in IE.

        • 2. Re: Could anyone help me out here regarding frame rate?
          whcodenza Level 1

          this project involves heaps of other elements such as xml file, timer

          but the code blow shows you the part where the frame rate gets changed

          just a reminder, this animition works perfectly in FF and by itself, the cursor loses control of the frame rate only in IE

           

          left_btn.addEventListener(MouseEvent.ROLL_OVER, leftRollOverHandler);
          function leftRollOverHandler(e:MouseEvent):void {
                  rewind=true;
                  if(this.currentFrame==157){
                      gotoAndStop(156);
                  }
                  var start_point:Number = left_btn.x + left_btn.width;
                  frame_rate = Math.round(1+(start_point - stage.mouseX)/(left_btn.width/12));

                  prevFrame();

          }
          left_btn.addEventListener(MouseEvent.ROLL_OUT, leftRollOutHandler);
          function leftRollOutHandler(e:MouseEvent):void {
              rewind=true;
          }

           

          right_btn.addEventListener(MouseEvent.ROLL_OVER, rightRollOverHandler);
          function rightRollOverHandler(e:MouseEvent):void {
                  rewind=false;
                  if(this.currentFrame==157){
                      gotoAndStop(158);
                  }
                  var start_point:Number = right_btn.x;
                  frame_rate = Math.round(1+(stage.mouseX - start_point)/(right_btn.width/12));
                  nextFrame()

          }

          function rightRollOutHandler(e:MouseEvent):void {
              rewind=false;
          }

           

           

          this.stage.addEventListener(Event.ENTER_FRAME,revFrame);
          function revFrame(e:Event):void {
              if (rewind == true) {
                  if(this.currentFrame == 157){  //this is for the time interval between each full spin
                      stop();
                      left_btn.mouseEnabled = false;
                      right_btn.mouseEnabled = false;
                      top_heading.mouseEnabled = true;
                      btm_heading.mouseEnabled = true;
                      timerRewindCounter.addEventListener(TimerEvent.TIMER,timerRewind);
                      timerRewindCounter.start();
                  }else{  //where it spins
                      left_btn.mouseEnabled = false;
                      right_btn.mouseEnabled = false;
                      btm_heading.text = "";
                      btm_shadow.text="";
                      link_toshow.htmlText = "";
                      prevFrame();
                  }
                  if (this.currentFrame == 2){
                      gotoAndStop(161);
                  }
              }else{ //winding
                  if(this.currentFrame == 157){
                      stop();
                      left_btn.mouseEnabled = false;
                      right_btn.mouseEnabled = false;
                      top_heading.mouseEnabled = true;
                      btm_heading.mouseEnabled = true;
                      timerCounter.addEventListener(TimerEvent.TIMER,timerContinue);
                      timerCounter.start();
                  }else{ // where it spins
                      left_btn.mouseEnabled = false;
                      right_btn.mouseEnabled = false;
                      btm_heading.text = "";
                      btm_shadow.text="";
                      link_toshow.htmlText = "";
                      nextFrame();
                  }
                  if(this.currentFrame == 161){
                      gotoAndStop(2);
                      nextFrame();
                  }
              }
              this.stage.frameRate = frame_rate;//frame rate changes
          }

          • 3. Re: Could anyone help me out here regarding frame rate?
            kglad Adobe Community Professional & MVP

            try:

             

            var frame_rate:int;
            var maxFrameRate:uint = 12;
            var factor:Number = Math.max(spinningObject.x,stage.stageWidth-spinningObject.x); // where spinningObject.x is the x property of you diamond

             

            function f(e:Event):void {
                frame_rate = Math.round(maxFrameRate*(spinningObject.x - stage.mouseX)/factor);
                  this.stage.frameRate = Math.max(1,Math.abs(frame_rate));
                if(frame_rate>0){
                    if(this.currentFrame<this.totalFrames){
                        this.nextFrame();
                    } else {
                        this.gotoAndStop(1);
                    }
                } else {
                    if(this.currentFrame>1){
                        this.prevFrame();
                    } else {
                        this.gotoAndStop(this.totalFrames);
                    }
                }
            }

             

            this.stage.addEventListener(Event.ENTER_FRAME,f);