3 Replies Latest reply on Jan 28, 2008 6:46 AM by stein olsen

    If's and but's

    stein olsen
      Hi,

      I'm new to action script and was hoping for a wee bit of help with some coding from anyone with an ear to listen. I'm working on a levels system for a website idea which I'm practicing on.

      I want to use a lot of levels, loading swf's into those levels when you click on the navigation. What I don't want though is once the swf is loaded into a level, and you click on the same button again, then it doesn't load that movie again and can just access the already loaded movie. I also want to be able to unload a big chunk of movies in many levels if need be.

      So what I was thinking was (taking a movie in level 10 as an example):

      on (release) {
      if (_root.level10=explosion.swf,true) {
      _root.level10.explosion.swf.gotoAndPlay(3) }
      }
      else {
      loadMovie ("explosion.swf",10);
      }

      Then to unload a lot of movies (say in levels 1-50) without having to put in loads of code can you use this?

      on(release) {
      unloadMovie(1-50)

      I'm not sure if any of this will work?

      Any help?

      Cheers,

      Stein.

        • 1. Re: If's and but's
          lilalfyalien
          Have you considered using a loop?
          • 2. Re: If's and but's
            rlc5611 Level 1
            if(_level10 <> undefined) {
            _level10.gotoAndPlay(3);
            } else {
            loadMovieNum("explosion.swf",10);
            }

            Of course if level10 is not loaded and someone repeatedly clicks the button with no delay, the movie would try to load and load. If the _level10, for example, was not yet loaded and you decide to load it, you should disable the button until it is loaded and then reenable the button.

            As far as unloading a bunch of levels, using unloadMovieNum in a loop would do just fine. On example:

            for(var i = 1; i <= 50; i++) {
            if(_root["_level" + i] <> undefined) {
            unloadMovieNum(i);
            }
            }
            • 3. Re: If's and but's
              stein olsen Level 1
              You lot are genius!

              Thank you very much. I must say it can be very daunting learning all this code but it's pretty cool stuff.