16 Replies Latest reply on Aug 10, 2007 6:58 AM by kglad

    Externally loaded SWF X&Y position

    jcedens
      I have spent the last 2 hours searching this forum for a solution to my problem. I have read more than 20 topics and tried them all...nothing works.

      My problem:

      I have a SWF that uses the following script to load another swf:

      loadMovieNum("Base/BASE_ALL.swf",2);

      I would like to place the "BASE_ALL.swf" exactly 100pixels below the top edge of the stage. The "BASE_ALL.swf" is w786 by h503, while my "container.swf" is w786 by h603.
      As you can guess, my problem lies with the fact that, no matter what I try, I can't force the "BASE_ALL.swf" to load, and re-position itself at _y = 100. This is very frustrating because I am sure that the answer is simple....

      Could anyone help?

      (Additional info: The "BASE_ALL.swf" externally loads numerous other SWF files depending on which buttons the user clicks in the menu - it's a website. All these files are w786 by h503. The only file that is h603 is the "container.swf". The "container.swf" is 100px taller in order to allow an area for a company logo that will remain visible regardless of where the user goes within the site.)
        • 1. Re: Externally loaded SWF X&Y position
          kglad Adobe Community Professional & MVP
          reference _level2 to position BASE_ALL.swf.
          • 2. Re: Externally loaded SWF X&Y position
            jcedens Level 1
            Didn't work (I could have entered it incorrectly though).....

            Here is what I have now:

            loadMovieNum("Base/BASE_ALL.swf",2);
            _level2._x = 0;
            _level2._y = 100;

            It loads the movie, but the "BASE_ALL.swf" still defaults to the upper left of the container.swf's stage....
            • 3. Re: Externally loaded SWF X&Y position
              kglad Adobe Community Professional & MVP
              you must wait until _level2 exists before you try to control any of its properties.

              if nothing has been loaded into it before the code you posted in your last message, then you must use preloader code to ensure BASE_ALL.swf has completed loading before trying to access the _x and _y properties of _level2.
              • 4. Re: Externally loaded SWF X&Y position
                jcedens Level 1
                OK,

                I have changed my code around to include a preloader for my swf.
                The following code is located in layer 1, frame 1 of the container.swf:

                -------------------------------------

                fscommand("fullscreen","true");

                this.createEmptyMovieClip("BASE_ALL", 999);
                var my_mcl:MovieClipLoader = new MovieClipLoader();

                // Create listener object:
                var mclListener:Object = new Object();
                mclListener.onLoadError = function(target_mc:MovieClip, errorCode:String, status:Number) {
                trace("Error loading image: " + errorCode + " [" + status + "]");
                };
                mclListener.onLoadStart = function(target_mc:MovieClip):Void {
                trace("onLoadStart: " + target_mc);
                };
                mclListener.onLoadProgress = function(target_mc:MovieClip, numBytesLoaded:Number, numBytesTotal:Number):Void {
                var numPercentLoaded:Number = numBytesLoaded / numBytesTotal * 100;
                trace("onLoadProgress: " + target_mc + " is " + numPercentLoaded + "% loaded");
                };
                mclListener.onLoadComplete = function(target_mc:MovieClip, status:Number):Void {
                trace("onLoadComplete: " + target_mc);
                };

                my_mcl.addListener(mclListener);

                my_mcl.loadClip("Base/BASE_ALL.swf", BASE_ALL);

                Stage.scaleMode = "noScale";
                Stage.align = "M";
                Stage.addListener(BASE_ALL);
                BASE_ALL._x = 0;
                BASE_ALL._y = 100;

                stop();

                ------------------------------------------------------------------------

                This all works, except I still can't get the mclip to shift itself, along with the loaded swf down by the 100 pixels to reveal the logo. (currently, it hugs the top of the stage, covering up the logo, and exposing 100 pixels of blank space along the bottom of the container.swf).

                What am I missing here????????
                • 5. Re: Externally loaded SWF X&Y position
                  kglad Adobe Community Professional & MVP
                  1. when you're loading into a movieclip (like BASE_ALL) instead of a _level, you don't need preloader code to ensure the movieclip exists. it exists as soon as you create it. so, you can assign its _x and _y properties any time after it's created.

                  2. what's mclip?
                  • 6. Re: Externally loaded SWF X&Y position
                    jcedens Level 1
                    1. Forgive me if I sound like a beginner, but, well...I am. I am trying to load BASE_ALL.swf into an empty movie clip located in another swf (referred to here as: container.swf). All the previously posted code exists in the container.swf. The empty movie clip I created in container.swf is called: BASE_ALL. Since I created the movie clip by the previously posted code, why doesn't the part work where I am trying to actually position it (any time after it's created).

                    BASE_ALL._x = 0;
                    BASE_ALL._y = 100;

                    2. mclip is short for movie clip

                    Thanks for your help....
                    • 7. Re: Externally loaded SWF X&Y position
                      kglad Adobe Community Professional & MVP
                      1. the code you posted in your last two messages should work without problem. BASE_ALL.swf's upper left should be at 0,100.

                      2. most people using flash use mc as short for movieclip, though even this can cause confusion unless it's within some context like, "i created an empty mc".
                      • 8. Externally loaded SWF X&Y position
                        jcedens Level 1
                        I know that it should work....

                        My question is: Can anyone figure out why it is not working?

                        Does it matter where the mc is placed on the stage in the container.swf?
                        • 9. Re: Externally loaded SWF X&Y position
                          kglad Adobe Community Professional & MVP
                          lol. which "the" mc?

                          it matters where BASE_ALL is positioned, but that shouldn't be changed by anything other than the script you've posted.

                          it you think BASE_ALL.swf is NOT loading with its upper left at 0,100, post a link to your container fla and BASE_ALL.fla.
                          • 10. Re: Externally loaded SWF X&Y position
                            jcedens Level 1
                            "the mc" was referring to the dynamically created one...but I see what you're saying, so nm...

                            I would love to send it to you, but as far as I know, I have no way of posting those files to a site for you to download... they are very small though, could I email them to you?
                            • 11. Re: Externally loaded SWF X&Y position
                              kglad Adobe Community Professional & MVP
                              yes, kglad@hotmail_removethis_.com.
                              • 12. Re: Externally loaded SWF X&Y position
                                kglad Adobe Community Professional & MVP
                                if you were loading lines.swf and nav.swf and main.swf into a BASE_ALL.swf, then positioning BASE_ALL.swf would position those loaded swfs.

                                but those swfs are not loading into BASE_ALL.swf. they are loading into _levels. and _levels do not inherit anything from the swf that causes them to exist.

                                so, you do need to use preloader code to ensure your _levels exist and when they do, you can position the _levels.

                                therefore, in container.swf you can remove all the code except the code that loads BASE_ALL.swf. and in BASE_ALL.swf you can use:

                                • 13. Re: Externally loaded SWF X&Y position
                                  jcedens Level 1
                                  Sweet.
                                  That worked great. Thank you.

                                  However, (there's always a however, right?) if I click on anything in my nav.swf menu bar, it loads my other content (everything else in the whole site is w786 by h503 as well) at that top left corner default position.......and, if i click on main, it loads everything back to that spot as well...

                                  Normally, I could look at that code you posted and tweak it, but it was a little over my head....(most of the stuff I know at this point came from studying the built-in help topics in Flash Pro8 - it didn't recognize a lot of the script that you used)
                                  • 14. Re: Externally loaded SWF X&Y position
                                    kglad Adobe Community Professional & MVP
                                    what target movieclip or level is nav using and what target movieclip or level is main using?
                                    • 15. Re: Externally loaded SWF X&Y position
                                      jcedens Level 1
                                      Ok, after further review, I was able to adapt that script you posted earlier. The other mc's that are loaded into the BASE_ALL.swf (nav, main, lines) using levels. All I did was put that script into each subsequent mc (only changing the target level reference: levelA = [ //targetlevelnumberhere// ]; ) which places each mc at the ._y = 100 position.

                                      Thanks again for all your help! (that script will answer a lot of questions about loading swfs into swfs - and trying to position them - that have been posted here in the past)
                                      • 16. Re: Externally loaded SWF X&Y position
                                        kglad Adobe Community Professional & MVP
                                        you're welcome.