3 Replies Latest reply on Jul 18, 2007 3:43 PM by nikos_golf

    why is       .parent  = this       useful?

    nikos_golf
      Hi, what is the purpose of

      text_lv.parent = this

      from

      var text_lv = new LoadVars();
      text_lv.load("images.txt");
      //refer the parent of the object in a property so we can access some function that
      //the parent have and inaccessible by the text_lv object.
      text_lv.parent = this;



      the code continues

      var img_mcl = new MovieClipLoader();
      var handler = new Object();
      var pos = 1;
      handler.ref = imageContainer_mc.imgbg_mc;
      //functions-----------------------
      handler.onLoadInit = function(target_mc) {
      //center the loaded image.
      target_mc._x = -target_mc._width/2;
      target_mc._y = -target_mc._height/2;
      //initialize the _alpha to 0 so we can animate the fade in effect.
      target_mc._alpha = 0;
      //this function will be explained later.
      tween(this.ref, mx.transitions.easing.Regular.easeOut, "_width", this.ref._width, target_mc._width+10, .5, true);
      tween(this.ref, mx.transitions.easing.Regular.easeOut, "_height", this.ref._height, target_mc._height+10, .5, true, _root, "finish");
      };
      handler.onLoadComplete = function(target_mc) {
      //do nothing. trace("image loaded");
      };
      text_lv.onLoad = function(success) { if (success) { trace("text loaded");
      this.parent.loadImage(text_lv["img1"]);
      }
      else { trace("loadin failed");
      }};