0 Replies Latest reply on Jun 25, 2006 2:21 AM by ihtus

    Speed ::-:: FlashPlayer -vs- Browser Plugin

    ihtus
      hi again!

      i have two cases of code:

      1.
      quote:


      function f1 (y,z)
      {
      return -9.8/1.5*Math.sin(y) ;
      }
      function f2(y,z)
      {
      return z;
      }

      import flash.display.BitmapData;

      var myBitmapData:BitmapData = new BitmapData(640, 480, true, 0xCCFFFFFF);

      var mc:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth());
      mc.attachBitmap(myBitmapData, this.getNextHighestDepth());

      var t=0, h=0.01, y=0.8*Math.PI, z=0, i=0;
      var k11=0, k12=0; k13=0, k14=0, k21=0, k22=0, k23=0, k24=0;

      //BUTTON

      on (release) {
      presstime=getTimer();

      _root.onEnterFrame=function() {
      time=getTimer()-presstime;

      k11=h*f1(y,z);
      k12=h*f1(y+h/2,z+k11/2);
      k13=h*f1(y+h/2,z+k12/2);
      k14=h*f1(y+h,z+k23);
      z=z+(k11+2*k12+2*k13+k14)/6;

      k21=h*f2(y,z);
      k22=h*f2(y+h/2,z+k21/2);
      k23=h*f2(y+h/2,z+k22/2);
      k24=h*f2(y+h,z+k23);
      y=y+(k21+2*k22+2*k23+k24)/6;


      myBitmapData.setPixel(Math.round(y*50+200),time/500, 0x000000);

      res1._rotation=90-180*y/Math.PI;
      text1.text='fi= '+res1._rotation;

      }
      }




      source code - http://ihtus.xmgfree.com/flash_sources/pendulum/1.fla
      swf - http://ihtus.xmgfree.com/flash_sources/pendulum/1.swf

      when i ctrl+enter it - works great!
      but if I ctrl+f12 (or open swf through a broswer) - the pendulum oscilates slower!
      WHY?


      2.
      quote:


      function f1 (y,z)
      {
      return -9.8/1.5*Math.sin(y) ;
      }
      function f2(y,z)
      {
      return z;
      }

      import flash.display.BitmapData;

      var myBitmapData:BitmapData = new BitmapData(640, 480, true, 0xCCFFFFFF);

      var mc:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth());
      mc.attachBitmap(myBitmapData, this.getNextHighestDepth());

      var t=0, h=0.01, y=0.8*Math.PI, z=0, i=0;
      var k11=0, k12=0; k13=0, k14=0, k21=0, k22=0, k23=0, k24=0;

      pendul=function() {
      time=getTimer()-presstime;

      k11=h*f1(y,z);
      k12=h*f1(y+h/2,z+k11/2);
      k13=h*f1(y+h/2,z+k12/2);
      k14=h*f1(y+h,z+k23);
      z=z+(k11+2*k12+2*k13+k14)/6;

      k21=h*f2(y,z);
      k22=h*f2(y+h/2,z+k21/2);
      k23=h*f2(y+h/2,z+k22/2);
      k24=h*f2(y+h,z+k23);
      y=y+(k21+2*k22+2*k23+k24)/6;


      myBitmapData.setPixel(Math.round(y*50+200),time/500, 0x000000);

      res1._rotation=90-180*y/Math.PI;
      text1.text='time= '+time/1000;

      }

      //BUTTON

      on (release) {

      presstime=getTimer();

      setInterval(pendul,1);

      }



      source code - http://ihtus.xmgfree.com/flash_sources/pendulum/2.fla
      swf - http://ihtus.xmgfree.com/flash_sources/pendulum/2.swf

      and the same problem:
      when i ctrl+enter it - works great!
      but if I ctrl+f12 (or open swf through a broswer) - the pendulum oscilates slower!
      WHY?

      So i realy need the application to work through broswer (player plugin) as it works in flashplayer!

      Accidentely (for 2'nd code case) i hitted several times the button - and the pendulum started to oscilate faster and faster.
      And I made some changes in button code
      quote:


      on (release) {

      presstime=getTimer();

      setInterval(pendul,1);
      setInterval(pendul,1);
      setInterval(pendul,1);
      setInterval(pendul,1);
      }


      I hit once and it oscilates faster then it did.

      So my big questions are:
      1) why can't broswer (ie, opera, firefox) just play the swf as flashplayer plays it?
      2) why when i put multi setInterval functions - it began oscilates faster in the browser, and also in flashplayer - but here much more faster!!!
      3) how can i make the speed of oscilations to be the same for browser player plugin, and for flashplayer?
      Is multi setInterval functions - the only way to make broswer play the movie as it should be?