2 Replies Latest reply on Jun 2, 2006 6:15 AM by liek04

    MovieClip problem

    liek04
      This seems to be a simple problem, but I can't figure out why I can't get the _width-property out of a MovieClip. I've been struggeling with this for six hours now... Please help.

      I've broken down the code into just these lines:

      this.createEmptyMovieClip("test_mc",this.getNextHighestDepth);
      test_mc.loadMovie("image_1.jpeg");

      trace(test_mc._width);

      But it won't trace the width, it just says "0".

      Can anybode please tell me what I'm doing wrong???
        • 1. Re: MovieClip problem
          Level 7
          You're code is right, but you have to remember that Flash is asynchronous,
          which means that it just process code in order and doesn't wait for a
          response from the previous bit of code (like C# and other languages do)

          What you need to use MovieClipLoader.loadClip(); which has built-in call
          back functions that will let you monitor the loading progress of whatever
          you are loading. The loadMovie() function has none of those.

          Here's a snipped from Flash's help files:

          var loadListener bject = new Object();

          loadListener.onLoadComplete = function(target_mc:MovieClip,
          httpStatus:Number):Void {
          trace(">> loadListener.onLoadComplete()");
          trace(">> =============================");
          trace(">> target_mc._width: " + target_mc._width); // 0
          trace(">> httpStatus: " + httpStatus);
          }

          loadListener.onLoadInit = function(target_mc:MovieClip):Void {
          trace(">> loadListener.onLoadInit()");
          trace(">> =============================");
          trace(">> target_mc._width: " + target_mc._width); // 315
          }

          var mcLoader:MovieClipLoader = new MovieClipLoader();
          mcLoader.addListener(loadListener);

          var mc:MovieClip = this.createEmptyMovieClip("mc",
          this.getNextHighestDepth());
          mcLoader.loadClip("MCF.jpg", mc);


          Hope this helps.


          • 2. Re: MovieClip problem
            liek04 Level 1
            Thanks man! That really helped. I'm a happy camper now.