1 Reply Latest reply on Mar 30, 2007 8:02 AM by Flamebg

    Loader listners problem in the code..

    Flamebg Level 1
      This code works like this: I have 3 folders with pics and I want them to load one after another, first from the first folder, then from the second and after that from the third folder. So what this code should be doing is to load fruit picture 1 and when loading is completed, it should start loading fruit picture 2 and so on till it reaches the last fruit picture where the code tells start the next function from begining which starts loading the mixer pics the same way as the fruit pics. They all load in the same loader.
      It works fine.. exactly the way I've described except one little thing.. when it finishes loading all of my fruit pics it goes to the next function loads the first of the mixer pics, starts loading the second of the mixer pics and then somehow it goes back to function1 tells that the last of the fruit pics is loaded and restarts the mixer function from begining... How the hell this happens... can someone enlighten me please ? Down below the actual code I've posted how this code traces so u can understand what I am talking about.

      stop();
      var k:Number;
      var l:Number;
      var m:Number;
      var listenerObject1:Object = new Object();
      var listenerObject2:Object = new Object();
      var listenerObject3:Object = new Object();
      var loadingProcess1:Function = function (j:Number, type:String) {
      k = j;
      trace("loading fruitPic "+j);
      this.loadingGallery_ldr.addEventListener("complete", listenerObject1);
      this.loadingGallery_ldr.contentPath = "images/fruits/fruitPic"+j+".swf";
      };
      var loadingProcess2:Function = function (j:Number, type:String) {
      l = j;
      trace("loading mixerPic "+j);
      this.loadingGallery_ldr.addEventListener("complete", listenerObject2);
      this.loadingGallery_ldr.contentPath = "images/mixers/mixerPic"+j+".swf";
      };
      var loadingProcess3:Function = function (j:Number, type:String) {
      m = j;
      this.loadingGallery_ldr.addEventListener("complete", listenerObject3);
      this.loadingGallery_ldr.contentPath = "images/people/peoplePic"+j+".swf";
      };
      listenerObject1.complete = function(eventObj:Object) {
      trace("fruitPic "+k+" Loaded");
      trace("k="+k);
      trace("total fruit pics="+_root.totalFruitPics);
      if (k<_root.totalFruitPics) {
      k = k+1;
      trace("Next fruit pic");
      loadingProcess1(k, "fruit");
      } else {
      trace("going to mixer pics");
      loadingProcess2(1, "mixer");
      }
      };
      listenerObject2.complete = function(eventObj:Object) {
      trace("mixerPic "+l+" Loaded");
      trace("l="+l);
      trace("total mixer pics="+_root.totalMixerPics);
      if (l<_root.totalMixerPics) {
      l = l+1;
      trace("next mixer pic");
      loadingProcess2(l, "mixer");
      } else {
      trace("going to people pics");
      loadingProcess3(1, "people");
      }
      };
      listenerObject3.complete = function(eventObj:Object) {
      if (m<_root.totalPeoplePics) {
      m = m+1;
      loadingProcess3(m, "people");
      } else {
      _root.panel1_mc.gotoAndPlay(2);
      _root.firstTimeLoadingPics_mc._visible = false;
      }
      };
      loadingProcess1(1,"fruit");


      Tracing this code shows:
      loading fruitPic 1
      fruitPic 1 Loaded
      k=1
      total fruit pics=34
      next fruit pic
      loading fruitPic 2
      fruitPic 2 Loaded
      k=2
      total fruit pics=34
      next fruit pic
      loading fruitPic 3
      fruitPic 3 Loaded
      k=3
      total fruit pics=34
      next fruit pic
      loading fruitPic 4
      fruitPic 4 Loaded
      k=4
      total fruit pics=34
      next fruit pic
      loading fruitPic 5
      fruitPic 5 Loaded
      k=5
      total fruit pics=34
      next fruit pic
      loading fruitPic 6
      fruitPic 6 Loaded
      k=6
      total fruit pics=34
      next fruit pic
      loading fruitPic 7
      fruitPic 7 Loaded
      k=7
      total fruit pics=34
      next fruit pic
      loading fruitPic 8
      fruitPic 8 Loaded
      k=8
      total fruit pics=34
      next fruit pic
      loading fruitPic 9
      fruitPic 9 Loaded
      k=9
      total fruit pics=34
      next fruit pic
      loading fruitPic 10
      fruitPic 10 Loaded
      k=10
      total fruit pics=34
      next fruit pic
      loading fruitPic 11
      fruitPic 11 Loaded
      k=11
      total fruit pics=34
      next fruit pic
      loading fruitPic 12
      fruitPic 12 Loaded
      k=12
      total fruit pics=34
      next fruit pic
      loading fruitPic 13
      fruitPic 13 Loaded
      k=13
      total fruit pics=34
      next fruit pic
      loading fruitPic 14
      fruitPic 14 Loaded
      k=14
      total fruit pics=34
      next fruit pic
      loading fruitPic 15
      fruitPic 15 Loaded
      k=15
      total fruit pics=34
      next fruit pic
      loading fruitPic 16
      fruitPic 16 Loaded
      k=16
      total fruit pics=34
      next fruit pic
      loading fruitPic 17
      fruitPic 17 Loaded
      k=17
      total fruit pics=34
      next fruit pic
      loading fruitPic 18
      fruitPic 18 Loaded
      k=18
      total fruit pics=34
      next fruit pic
      loading fruitPic 19
      fruitPic 19 Loaded
      k=19
      total fruit pics=34
      next fruit pic
      loading fruitPic 20
      fruitPic 20 Loaded
      k=20
      total fruit pics=34
      next fruit pic
      loading fruitPic 21
      fruitPic 21 Loaded
      k=21
      total fruit pics=34
      next fruit pic
      loading fruitPic 22
      fruitPic 22 Loaded
      k=22
      total fruit pics=34
      next fruit pic
      loading fruitPic 23
      fruitPic 23 Loaded
      k=23
      total fruit pics=34
      next fruit pic
      loading fruitPic 24
      fruitPic 24 Loaded
      k=24
      total fruit pics=34
      next fruit pic
      loading fruitPic 25
      fruitPic 25 Loaded
      k=25
      total fruit pics=34
      next fruit pic
      loading fruitPic 26
      fruitPic 26 Loaded
      k=26
      total fruit pics=34
      next fruit pic
      loading fruitPic 27
      fruitPic 27 Loaded
      k=27
      total fruit pics=34
      next fruit pic
      loading fruitPic 28
      fruitPic 28 Loaded
      k=28
      total fruit pics=34
      next fruit pic
      loading fruitPic 29
      fruitPic 29 Loaded
      k=29
      total fruit pics=34
      next fruit pic
      loading fruitPic 30
      fruitPic 30 Loaded
      k=30
      total fruit pics=34
      next fruit pic
      loading fruitPic 31
      fruitPic 31 Loaded
      k=31
      total fruit pics=34
      next fruit pic
      loading fruitPic 32
      fruitPic 32 Loaded
      k=32
      total fruit pics=34
      next fruit pic
      loading fruitPic 33
      fruitPic 33 Loaded
      k=33
      total fruit pics=34
      next fruit pic
      loading fruitPic 34
      fruitPic 34 Loaded
      k=34
      total fruit pics=34
      going to mixer pics
      loading mixerPic 1
      mixerPic 1 Loaded
      l=1
      total mixer pics=12
      next mixer pic
      loading mixerPic 2
      fruitPic 34 Loaded
      k=34
      total fruit pics=34
      going to mixer pics
      loading mixerPic 1
      mixerPic 1 Loaded
      l=1
      total mixer pics=12
      next mixer pic
      loading mixerPic 2
      fruitPic 34 Loaded
      .....
      and so on and so on...