6 Replies Latest reply on Dec 21, 2007 11:50 AM by jerry@fcds

    MovieClip width

    jerry@fcds
      Not a first for this topic but other answers on the forum don't seem to work...

      I'm using MovieClips to do a fading "slideshow" using external jpgs. I'd like to center the jpgs on the Stage. I'm using a MovieClipLoader, creating a listener, and getting the clip width in the listener's onLoadComplete function. Someone recommended this over loadClip and onLoad - however the clip width is still coming out as 0.

      Help!
        • 1. Re: MovieClip width
          Level 7
          jerry@fcds

          > I'd like to center the jpgs on the Stage. I'm using a MovieClipLoader,
          > creating a listener, and getting the clip width in the listener's
          > onLoadComplete function.

          That sounds like a good way to do it. You might try handling the
          onLoadInit event instead ... for JPGs, onLoadInit shouldn't come into
          play -- it waits for any actions of the loaded content's frame 1 to execute
          (which JPGs don't have) -- but it doesn't hurt, and it fires slightly after
          onLoadComplete.

          > Someone recommended this over loadClip and onLoad

          Yes. As long as your publishing to Flash Player 7 or higher, it's the
          better (easier to deal with) route.

          > however the clip width is still coming out as 0.

          Let's see your code ... maybe there's something missing somewhere.


          David Stiller
          Co-author, Foundation Flash CS3 for Designers
          http://tinyurl.com/2k29mj
          "Luck is the residue of good design."


          • 2. Re: MovieClip width
            Damon Edwards Level 3
            try changing the onLoadComplete to onLoadInit. If this doesn't work, there is something else wrong. possible scope issue.
            • 3. Re: MovieClip width
              jerry@fcds Level 1
              Here's the code:

              fileToLoad = _root.imageArray[_root.imageIndex];
              fileToLoad = "art/home_page/" + fileToLoad;
              //loadMovie(fileToLoad,"myClip1"); this is where I started.

              //Here's the new attempt.
              this.createEmptyMovieClip("myClip1", 0);
              var my_mcl:MovieClipLoader = new MovieClipLoader();
              var mclListener:Object = new Object();
              mclListener.onLoadComplete = function(myClip1:MovieClip, status:Number):Void {

              theWidth = myClip1._width;
              //I've also tried getBounds() and getRect() with no success... the following came from the Help file.
              //var boundsObj:Object = myClip1.getRect();
              //trace(boundsObj.xMin); // 0
              //trace(boundsObj.yMin); // 0
              //trace(boundsObj.xMax); // 20
              //trace(boundsObj.yMax); // 80
              };
              my_mcl.addListener(mclListener);
              my_mcl.loadClip(fileToLoad,"myClip1");


              Thanks for the response!
              • 4. Re: MovieClip width
                Level 7
                jerry@fcds,

                > //I've also tried getBounds() and getRect() with no success...

                Until Flash Player recognizes the JPG as fully loaded, none of the
                width-related (any sort of dimensions-related) properties are going to seem
                valid.

                Your code looks fine to me (thought I might see something amiss in
                context). Have you tried onLoadInit, as dzedward also suggested? Let's see
                if that one does any better. Again, with JPGs, the concept of onLoadInit
                doesn't especially make sense -- they have no frame 1, and there certainly
                isn't any ActionScript involved in the loaded file -- but give it a shot
                anyway and let me know if that does it.


                David Stiller
                Contributor, How to Cheat in Flash CS3
                http://tinyurl.com/2cp6na
                "Luck is the residue of good design."


                • 5. Re: MovieClip width
                  Level 7
                  As the others said - change your onLoadComplete to onLoadInit. I never use
                  anything but onLoadInit - and I never have any issues loading and sizing
                  images.

                  --
                  Dave -
                  Head Developer
                  http://www.blurredistinction.com
                  Adobe Community Expert
                  http://www.adobe.com/communities/experts/


                  • 6. Re: MovieClip width
                    jerry@fcds Level 1
                    Hallelujah! onLoadInit it is! My little slideshow looks SO much better centered ( http://www.lindagarrettbattle.com/). Thanks for the help. And have a happy holiday!

                    Jerry
                    Webmaster
                    http://www.fcds.org/