1 Reply Latest reply on Aug 4, 2006 2:52 AM by Newsgroup_User

    Can't get code to work!

    discodotti
      Hi guys
      i just can't figure out why this bit of code I kindly given yesterday won't work, maybe I'm doing something very stoopid
      the swf that I am trying to load in (press.swf) is still coming in right at the top of my main home movie, the x and y co ordinates (100 and 200) don't seem to be applied. Also, does anyone know what the 100 value is for on the code that is attcached to the button?
      Thanks everyone :-)

      // Code on button:

      on (release) {
      unloadMovieNum(1);
      loadMovieNum("Press.swf", 2);
      _parent.preloadI=setInterval(_parent.preloadF,100);
      }

      // the below should be attached to a frame that contains the above button

      function preloadF(){
      bl=_level2.getBytesLoaded();
      bt=_level2.getBytesTotal();
      if(bl>0&&bl>=bt){
      clearInterval(preloadI);
      _level2._x=100;
      _level2._y=200;
      }
      }
        • 1. Re: Can't get code to work!
          Level 7
          It may be a scoping issue. You are using _parent to assign the interval, but
          assuming your release handler is on a button instance that may not be right.
          Put a simple trace into the preloadF function to make sure it is being
          called by the interval:

          function preloadF(){
          trace ("!! interval called !!");
          bl=_level2.getBytesLoaded();
          bt=_level2.getBytesTotal();
          if(bl>0&&bl>=bt){
          clearInterval(preloadI);
          _level2._x=100;
          _level2._y=200;
          }
          }


          If you see no trace, then change your handler to :

          on (release) {
          unloadMovieNum(1);
          loadMovieNum("Press.swf", 2);
          preloadI=setInterval(preloadF,100);
          }

          The 100 value here is the time in milliseconds between the interval being
          called - i.e. every tenth of a second in this case.

          --
          -------------------------------
          Remove '_spamkiller_' to mail
          -------------------------------