5 Replies Latest reply on May 26, 2011 9:26 AM by UdaySingh

    Bug: Cannot attach after failed loadClip

    Harry Kunz Level 4

      Hi, this is sort of a bug report unless somebody in this forum can prove me wrong. I've stumbled several times across this problem in my project always scratching my head of this undesirable behavior until i finally decided to create a simpler script to reproduce the problem. Here it goes. If you attempt to load an image into a movie clip and the load fails, you are unable to attach a library movie clip to it. The code below is from the fla file i attached herewith. All you need is a movieclip in your library with linkage name "Attach_MC" and this script in a 1-frame fla file. Or just download the fla file. What i am trying to do is attach a movieclip with a graphic that says "loading failed" if the load fails, so that it won't be blank but i can't do it unless perhaps by a workaround by placing a reserve clip in the same place (i.e. under a mask).

       

      import mx.utils.Delegate;

       

      var mcGlobal:MovieClip = this.createEmptyMovieClip("Stage_MC", 0);

      var cLoader:MovieClipLoader = new MovieClipLoader();

      var oListener:Object = new Object();

      oListener.onLoadInit = Delgate.create(this, onLoadSuccess);

      oListener.onLoadError = Delegate.create(this, onErrLoad);

      cLoader.addListener(oListener);

      cLoader.loadClip("intentional_wrong_path", mcGlobal);

       

      function onLoadSuccess(fSuccess:Boolean):Void {}

      function onErrLoad(mcClip:MovieClip):Void

      {

         trace("Clip: " + mcClip); //Exists = mcGlobal

         var mcNested:MovieClip = mcClip.createEmptyMovieClip("Empty_MC",0);

         trace("Empty_MC: " + mcNested); //Creating Empty MC works

       

         //But attaching does not work!!! Undefined!!

         var mcAtt1:MovieClip = mcNested.attachMovie("Attach_MC", "Att_MC", 10);

         var mcAtt2:MovieClip = mcClip.attachMovie("Attach_MC", "Att_MC", 10);

         trace("Att1_MC: " + mcAtt1);

         trace("Att2_MC: " + mcAtt2);

      }

       

      Any responses pertaining to this problem are highly appreciated.