4 Replies Latest reply on Sep 6, 2006 7:51 AM by Craig Grummitt

    What is wrong with this code?

      I'm cross-eyed looking at this thing! Please help!

      Trying to load resize and reposition an external swf when I click a button. The code below is on the button. Plus, I need to put a button on top of the movie clip so the user can (at any time) click to go back to the a main menu. Figured I would load the swf into level 1 and place the button on top in another layer. WRONG! I have no idea what is wrong. Thanks in advance.

      on (release) {
      _root.movie1_1._x = 0;
      _root.movie1_1._y = 0;
      _root.movie1_1._width = 267;
      _root.movie1_1_height = 147;
        • 1. Re: What is wrong with this code?
          Craig Grummitt Level 3
          first i think you're getting confused between layers, levels and depth. have a look here.

          when creating an empty movie clip, where you've written '_level1', you need to put a depth, not a level.

          also, you need to wait until a swf has been loaded before you can manipulate its width and height. the movieclip loader class is the easiest way of achieving this. there are examples to follow here.
          • 2. Re: What is wrong with this code?
            DragonTheory.com Level 1
            Thank you for responding. Unfortunately I am stuck coding for Flash Player 6. The article says this availability is Flash Player 7. How does that effect the code? Please pardon my ignorance but I have created an empty movie clip. Do I still need to create a MovieClipLoader? What would the code look like? Is this part of a "preloader" that you can see the progress of the download? So if the SWF is called movie.swf should the code be: MovieClipLoader.loadClip(movie.wf)? And will that do it all or is there more to code to resize and reposition the SWF? Thanks again for you time.
            • 3. Re: What is wrong with this code?
              DragonTheory.com Level 1
              Oh and where should I put this code? On the button, on the timeline or on the movie clip? Thanks again.
              • 4. Re: What is wrong with this code?
                Craig Grummitt Level 3
                that's a lot of question marks! let me see if i can answer some of them.

                so you're stuck with flash player 6 hey? that's a shame. yes movieclipLoader was introduced in Flash MX 2004 so you won't be able to use it, but you can still test if a movieclip has loaded. rather than take you through it, i figured someone must have already written a tutorial so googled this for you - check out a tutorial at david stiller's blog (thanks david) read up until the heading "Another answer, short and sweet" - you can't use that one sorry! where it says "trace("Loading complete!");" you should put your code for resizing your swf.

                other answers - yes this is like a preloader except all its doing at the moment is testing for completion - you can change the code if you like to do something like display a percentage as it loads to make it a true preloader.

                Oh and where should you put this code? in all instances it is best practice to put code on the frame - on the timeline.