4 Replies Latest reply on May 15, 2008 8:42 AM by Rothrock

    Load Movie and the size of the movie

    Sunnyspring
      We have used loadMovie to load some small SWF files on a home page we have made. The swf files are in different sizes and we need to be able to set the size. How do we do this?
      We hoped the problem was solved with the following code, but this code only sets the size of the variabel "minRamme, the contents are still to big, resulting in only a part of the swf file being visible.
      Anyway the following code doesn't work on the button, but works when the button command is put aside. How come?

      knapp.onRelease = function() {
      minRamme = this.createEmptyMovieClip("clip",0);
      minRamme.loadMovie("ann kristin.swf");
      minRamme.height = 400;
      minRamme.width = 600;
      minRamme._x = 0;
      munRamme._y = 0;
      }

      Thanks in advance!

      Sol
        • 1. Re: Load Movie and the size of the movie
          Level 7
          >>knapp.onRelease = Function(); {

          Fix that to be: knapp.onRelease = function(){


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


          • 2. Re: Load Movie and the size of the movie
            robdillon Most Valuable Participant
            You are creating a new, empty movieClip. Then you load in an external .swf into that clip. You have a typo in the line: munRamme._y = 0;, but that won't matter in this instance, because, if you don't specify an x and y position for the new movieClip, it will be positioned at point 0,0, the upper left corner of the stage. Since you are using AS2, the property names are _width and _height for the clip's width and height properties. The way that you have this written, you are creating two new properties for the movieClip. That's perfectly legal, but not at all what you want.

            When you import an external .swf, it will import at its original size. If you don't want to change the size, then don't specify a _width or _height value. So, if you want to import this .swf, keep it at its original size and position it in the upper left corner, then leave out everything after the loadMovie() call.
            • 3. Re: Load Movie and the size of the movie
              Sunnyspring Level 1
              Thanks for your answers, I haven't been here for a week, and haven't had the time to look into the problem. But we do need to change the size of the swf files we load since they are all to be shown in the same window, and originally they have different sizes.
              Do we need a preloader here, or can we get around the problem with some simple commands?

              Sol
              • 4. Re: Load Movie and the size of the movie
                Rothrock Level 5
                Well you have several problems. First is just a stylistic question. You create an empty moveie called "clip" and assign its reference to a variable called "minRamme." That is a perfectly legit thing to do, but I wonder why. Generally I use the variable as a sort of shorthand or short cut to refer to the clip -- something easier to type without mistakes. In this case you are making it more difficult. So personally I would change those around, but that is for you to decide.

                The next is also a stylistic thing. You are creating the clip at a depth of zero. Again a perfectly legit depth. However you have more than a million depths to pick from, and who knows, next week you might want something to be under minRamme so I would encourage you to at least move it up to 10.

                Okay now on to the three problems that are left. (I think you only know about one at this point!).

                When you use loadMovie there is a pause between the time the request is made and the time the movie actually loads.It can be quite quick (but still not zero) if you are testing locally on your machine or quite long over a dial up internet connection. And it won't always be the same so you can't guess exactly what it will be. So when you try and set the width and the height they aren't avaialbe for setting.

                One problem is that you are mixing your AS3 and AS2 code. Under AS2 -- which is where you will have createEmptyMovieClip() -- the properties are _width and _height. The underscores are dropped in AS3.

                So you need some technique to check to make sure your movie is loaded before you try and set its _width and _height. You could start an onEnterFrame or setInterval that polls the loading clip to see how many bytesLoaded vs bytesTotal. This is what is known as an old-school preloader. Or you could use the MovieClipLoader class. It has a nice onLoadInit event that will tell you when the clip is ready. Check it out in the help files and post back if you want to go that way.

                But even then you are going to have another problem. The published stage size settings are not part of the information available to you when you load an external swf. You mentioned that orginally they had different sizes. So when they load you won't know what sizes to set the external files to. It all depends upon how they are laid out and what the content on the first frame is like.