4 Replies Latest reply on Sep 12, 2006 1:23 AM by Peter Lorent

    Scope problem when using MovieClipLoader within a class file

    Neil Hand
      Hi All,

      I have a problem that i hope someone can help me with before i pull out what is left of the hair that i have.

      I have defined a new class withing AS2 (not an extension to an existing class) to manage some thumbnails on a gallery site i am building. Within this class i am building a movie clip, and beneath that movieclip creating more clips to load the thumbnails i am interested in.

      To simplify the loading of these thumbnails i am trying to use the MovieClipLoader class. However i seem to be hitting a scopeing problem on the callback rountines.

      I am registering the callbacks as part of the creator function (shown in the code example below). The callbacks are working fine, however the functions i am trying to call from within the callbacks all appear as undefined. Using the output of the code below as an example, i get the trace of "loaded" but not the trace of "here".

      Placing all my function code directly in the callback works, however since i also want to have the option of calling the functions at other times (for example to reformat after some parameter changes) i would rather not have two copies of the code.

      class com.debug.ex1 {
      private var __myMC:MovieClip;

      private var myloader:MovieClipLoader;
      private var mylistener:Object = new Object();

      public function myfunction():Void {
      trace("Debug: Here");

      public function ex1 (root_mc:MovieClip, myArray:Array) {

      var selDepth:Number = root_mc.getNextHighestDepth();
      var selName:String = "MC_"+String(selDepth);

      __myMC = root_mc.createEmptyMovieClip(selName, selDepth);

      myloader = new MovieClipLoader();
      mylistener.onLoadInit = function(target_mc:MovieClip, httpStatus:Number):Void {
      trace("Debug: loaded");


      If anyone can give me any guidenace as to what i am doing wrong it would be greatly appriciated.
      Best Regards