2 Replies Latest reply on Apr 27, 2006 12:25 AM by nurg1e

    Performance problem (with onEnterFrame?)

    nurg1e
      Hi.
      I'm working on a pretty big product presentation in flash. The presentation is "doable" with like no AS at all, but the timeline(s) would be huge and a nightmare to work with, therefore I like to do as much as possible with AS.

      My problem is that my MC gives me 50-90% cpu-load on a 1,6Ghz P4 which results in like 1fps, in all other aspects everything works like intended.
      My big question is "Can I lower this load by doing everything (or parts of it) without AS? or is my code some where very bad written?"

      My suspicions goes to my _root.onEnterFrame=function(){} where everything happens (mostly thou function calls). Let me explain the movies structure:
      I have 3 subsections (the first containing 5 steps) that is repeated 5 times so the loop looks something like this ( on _root on the first (and only) frame:

      step = subSet=bigSet=0;
      onEnterFrame = function () {
      if( bigSet < 6 ) {
      if (subSet == 0) {
      if (isFirstStepInSubSet) {
      doFirstStepInSubSet(0);
      step++;
      } else if (isNotFirstAndNotLastStepInSubSet) {
      doNotFirstAndNotLastStepInSubSet(step);
      step++;
      } else if (isLastStepInSubSet) {
      doLastStepInSubSet(lastStep);
      step = 0;
      subSet++;
      }
      } else if (subSet == 1) {
      doFadeOfSubSet(subSet);
      doSubSet(subSet);
      subSet++;
      } else if (activeSubSet == 2) {
      doFadeOfSubSet(subSet);
      doSubSet(subSet);
      subSet = 0;
      bigSet++;
      }
      }
      };
      Keep in mind that this is just an example code to explain the thinking.

      The real code (for those of you that haven't fled away yet ) is like this:
      Please download it here!

      Thanks for any thoughts at all!
        • 1. Re: Performance problem (with onEnterFrame?)
          Level 7
          nurg1e wrote:

          > Hi.
          > I'm working on a pretty big product presentation in flash. The presentation is
          > "doable" with like no AS at all, but the timeline(s) would be huge and a
          > nightmare to work with, therefore I like to do as much as possible with AS.
          >
          > My problem is that my MC gives me 50-90% cpu-load on a 1,6Ghz P4 which results
          > in like 1fps, in all other aspects everything works like intended.
          > My big question is "Can I lower this load by doing everything (or parts of it)
          > without AS? or is my code some where very bad written?"
          >
          > My suspicions goes to my _root.onEnterFrame=function(){} where everything
          > happens (mostly thou function calls). Let me explain the movies structure:
          > I have 3 subsections (the first containing 5 steps) that is repeated 5 times
          > so the loop looks something like this ( on _root on the first (and only) frame:
          >
          > step = subSet=bigSet=0;
          > onEnterFrame = function () {
          > if( bigSet < 6 ) {
          > if (subSet == 0) {
          > if (isFirstStepInSubSet) {
          > doFirstStepInSubSet(0);
          > step++;
          > } else if (isNotFirstAndNotLastStepInSubSet) {
          > doNotFirstAndNotLastStepInSubSet(step);
          > step++;
          > } else if (isLastStepInSubSet) {
          > doLastStepInSubSet(lastStep);
          > step = 0;
          > subSet++;
          > }
          > } else if (subSet == 1) {
          > doFadeOfSubSet(subSet);
          > doSubSet(subSet);
          > subSet++;
          > } else if (activeSubSet == 2) {
          > doFadeOfSubSet(subSet);
          > doSubSet(subSet);
          > subSet = 0;
          > bigSet++;
          > }
          > }
          > };
          > Keep in mind that this is just an example code to explain the thinking.
          >
          > The real code (for those of you that haven't fled away yet ) is like this:
          > Please download it http://www.liljengrens.se/vexplain.rar!
          >
          > Thanks for any thoughts at all!

          instead use setInterval. It's better on the performance.

          -Richard


          • 2. Performance problem (with onEnterFrame?)
            nurg1e Level 1
            I've tryed it and it lowered my cpu-load by almost 20%
            Thanks man!!