16 Replies Latest reply on Apr 4, 2007 4:20 PM by crazyjoemilan

    PreLoader causing component problem

    sbryner Level 1
      Hey all,

      I have a created a site that has a scene preloader that preloads my main.swf.
      My main.swf then has a preloader for each external .swf file loaded into it.

      Everything seems to work it preloads my main.swf showing the percent loaded.
      Once it's loaded it appears and then loads an .swf file into a loader component (this works)

      Problem:
      the buttons inside the external .swf (that is loaded into my loader component) do not work. What could be wrong?
      I'm thinking it's just a problem with the scope. Below is my script I'm using.

      thanks in advance,
      sky

        • 1. Re: PreLoader causing component problem
          crazyjoemilan Level 2
          trace("frame is loaded");
          hello_btn.onRelease = function () {
          trace("i'm craaaaaaaaaaaaaaaaaazy");
          };

          put a trace in your button to see where you're code is broken.
          • 2. Re: PreLoader causing component problem
            sbryner Level 1
            Hey Mr Helpy mcHelpson,

            thanks for the reply. I read both traces you suggested.

            (referencing the last posted)
            It does work if the value of my comboBox is "defaultValue" it will set the the text of
            Warning_txt.text = "Select Option";

            when I click the hello_btn and my comboBox is set to a value say "hello.swf" it will not open the file in the loader
            so it appears the line I'm having the problem is:

            _root.mcLoader.loadClip("hello.swf", bigLoader)

            the bigLoader (loader component) is in my main.swf file on it's own layer.

            hierarchy is like this:
            preloader scene (preloads main.swf)
            |
            main.swf (contains a loader component)
            |
            external .swf (preloads in loader component)
            |
            hello.swf (file loads with buttons components or _mc buttons)
            * note neither the component buttons or _mc buttons will work
            that another reason why I think it's a scope issue and not a
            components issue.

            with that what else could I do?
            recaping: Clicking the help_btn works it just isn't loading my .swf movie in the loader component on the main.swf.


            • 3. Re: PreLoader causing component problem
              crazyjoemilan Level 2
              I think you might be referencing loadClip wrong, but I'm not entirely sure, so here's what I'd do.

              _root.mcLoader.loadClip("hello.swf", bigLoader)
              //try for kicks
              _root.mcLoader.bigLoader.loadMovie("hello.swf")
              //then build your loader on your main timeline, so you can try
              _root.loadClip("hello.swf", bigLoader)

              if i'm completely off here, let me know, and I'll be glad to right myself, otherwise, let me know what happens with those.
              • 4. Re: PreLoader causing component problem
                sbryner Level 1
                I'm starting to loose it here (smile),

                on my main.swf I have a layer with the loader component (bgLoader) on it when I check the scope it appears to be on the _root timeline so that should be ok, correct?

                in my externally loaded swf I initially had:
                _root.mcLoader.loadClip("hello.swf", bigLoader)
                Doesn't work

                then I tired your next bit:
                _root.mcLoader.bigLoader.loadMovie("hello.swf")
                Doesn't work

                then lastly I tried:
                _root.loadClip("hello.swf", bigLoader)
                Doesn't Work

                Also,
                I've put a trace on my button like this
                trace(comboBox.value);
                which does trace the correct value when I release the button

                so then I thought heck why not put it in a global variable and try and access it that way?
                I then tried in my external loaded .swf

                _global.extBtn;
                and in my onrelease code I set the variable to comboBox.value and it traces correctly as well
                so when I go back to my main.swf and play it traces all the correct info.

                so in my main.swf I added a line and maybe I'm not calling it correctly but I did this

                mcLoader.loadClip(extbtn, bigLoader);
                which I thought would send the extBtn variable to my bigLoader
                but nothing changes.

                any ideas?
                • 5. Re: PreLoader causing component problem
                  sbryner Level 1
                  Oh,

                  also tried:

                  _root.mcLoader.loadClip("hello.swf", _root.bgLoader);
                  • 6. Re: PreLoader causing component problem
                    crazyjoemilan Level 2
                    _root.mcLoader.bigLoader

                    this loadClip or loadMovie function using the above path says that bigLoader is not, in fact on the _root timeline. I should've noticed that mcLoader is in fact your movieClipLoader(). gah, silly me.

                    try this while I try to recreate your problem on my machine.

                    _root.bigLoader.loadMovie("hello.swf")

                    I'm sorry you're starting to lose it, but I think we can get it soon here, we have enough tests that we know what its not.
                    • 7. Re: PreLoader causing component problem
                      Level 7
                      Just a guess, but could it be that the loaded swf has its _lockroot property
                      set to true? If that's the case, _root from within the loaded clip will not
                      be synonymous with _level0.



                      • 8. Re: PreLoader causing component problem
                        crazyjoemilan Level 2
                        var mcLoader:MovieClipLoader = new MovieClipLoader;
                        var mcListener:Object = new Object();
                        mcLoader.addListener(mcListener);
                        this.createEmptyMovieClip("bL", 1);
                        bL.mcLoader = new MovieClipLoader();
                        bL.mcListener = new Object();
                        bL.mcLoader.addListener(mcListener);
                        this.bL.createEmptyMovieClip("bigLoader", 1);

                        mcLoader.loadClip("hello.swf", bL.bigLoader)

                        works for me. I create an MC, then another MC inside of that MC, then try to load a movieClip into it. note the path works not in front of loadClip, but in the arguments.
                        • 9. Re: PreLoader causing component problem
                          sbryner Level 1

                          I have a loader component on a layer in my main movie named "bgLoader".
                          In my actions layer in my main movie I also have the code below:
                          /*
                          mcLoader.addListener(mcListener);

                          mcListener.onLoadProgress = function (target_mc, bytesLoaded,bytesTotal) {
                          extLoader_mc._visible = true;
                          var pctLoaded = Math.round((bytesLoaded/bytesTotal)*100);
                          extLoader_mc.pctLoaded_txt.text = pctLoaded;
                          extLoader_mc.loaderBar_mc._xscale = pctLoaded;
                          if(pctLoaded>=12){
                          extLoader_mc.loaderBar_mc._visible=true;
                          }
                          if(bytesLoaded >= bytesTotal){
                          extLoader_mc._visible = false;
                          }
                          };

                          mcLoader.loadClip("intro.swf", bigLoader);

                          */

                          then in the file that is loaded into my bgLoader I have buttons both component and _mc's and neither will load.
                          the code for the buttons in the .swf that is loaded into bgLoader (loader component) is
                          ########################
                          // comboBox.value = hello.swf
                          ########################
                          component_btn.onRelease = function () {
                          if(comboBox.value == "defaultValue"){
                          warning_txt.text = "Select Option";
                          }else{
                          warning_txt.text = ""; // works!
                          //_root.mcLoader.loadClip("hello.swf", _root.bgLoader);
                          _root.bgLoader.loadMovie(comboBox.value);
                          trace(comboBox.value); // works!

                          }

                          };
                          • 10. PreLoader causing component problem
                            crazyjoemilan Level 2
                            var mcLoader:MovieClipLoader = new MovieClipLoader;
                            var mcListener:Object = new Object();
                            mcLoader.addListener(mcListener);
                            this.createEmptyMovieClip("bL", 1);

                            this.bL.createEmptyMovieClip("bigLoader", 1);

                            tVar = "hello.swf" // could you just define tVar as comboBox.value -- note that its value type should be a string.

                            mcLoader.loadClip(tVar, bL.bigLoader) //works for me.
                            ///////////////
                            EDIT: I'm not sure why you're using ".value" as a variable name, but I'll assume you're not, and that its just the way the component is working. I'm not able to set the value to a string in my .fla.
                            • 11. Re: PreLoader causing component problem
                              sbryner Level 1
                              if you mean inside the trace ( comboBox.value) I was just checking to make sure I was getting the correct value to send to my movieClipLoader.

                              I can't seem to get the tVar to load the comboBox.value is the problem.
                              I don't have the movieClipLoader in my externally loaded file but in my main.swf .

                              I can't even get a _global variable to read from my external loaded .swf to read to trace in my main.swf (make sense?)

                              you also have two mc's one loading in another.
                              I have a loader that loads swf inside it. could that make a difference? it worked until I added the preloader mcLoader function to it.
                              • 12. Re: PreLoader causing component problem
                                crazyjoemilan Level 2
                                I have a loader that loads swf inside it. could that make a difference? it worked until I added the preloader mcLoader function to it.

                                You have code in an intro movie that should be overwriting itself, this should probably be controlled outside of the loaded movie, instead of on top of itself. I think if you changed that, even if you still had a problem, it would be much easier to look for.
                                • 13. Re: PreLoader causing component problem
                                  sbryner Level 1
                                  sorry, I don't get it.

                                  I've tried what you said but it doesn't appear to work.

                                  this works.
                                  _root.bigLoader.loadMovie(comboBox.value);
                                  it loads fine but without the preloader bar working.
                                  (bigLoader is tangible and on the stage)

                                  but when I call this
                                  _root.mcLoader.loadClip(comboBox.value);
                                  it ignores everything. (mcLoader is only in my actionscript)

                                  Question:
                                  Why wouldn't my _global variables work?

                                  main.swf has a _global variable of
                                  _global.links;

                                  in my externally loaded swf I can set it using
                                  links=comboBox.value;

                                  but when I try to read it back in my main.swf it says undefined.
                                  any idea?

                                  I really want to be able to open a new swf inside bigLoader using a button
                                  currently inside the loader component.

                                  what I declared the movieClipLoader class in each .swf loaded into my bigLoader component?
                                  • 14. Re: PreLoader causing component problem
                                    crazyjoemilan Level 2
                                    this works.
                                    _root.bigLoader.loadMovie(comboBox.value);
                                    it loads fine but without the preloader bar working.
                                    (bigLoader is tangible and on the stage)


                                    var mcLoader:MovieClipLoader = new MovieClipLoader;
                                    var mcListener:Object = new Object();
                                    mcLoader.addListener(mcListener);
                                    this.createEmptyMovieClip("container",1);

                                    _root.mcLoader.loadClip(comboBox.value, container);

                                    if loadMovie works, but loadClip doesn't (which by the way we left out an arguement in the loadClip) then we know our problem isn't with the variable. It may be where the variable is being called from in the function, but I imagine after what we've looked at that its something more simple.

                                    I would create a second movieClip on the root timeline, and see if you can't use your loadClip to hit it from your loaded mc. (in the example above "container"). Make sure, though, that your loadClip function is how it should be instead of some other version we've been messing with as a test.
                                    • 15. Re: PreLoader causing component problem
                                      sbryner Level 1
                                      I don't get it but this just started working.
                                      wierd I've tried it a bunch of times and now it works. I just started from
                                      scratch and redid the whole thing.

                                      _root.mcLoader.loadClip(island.value, _root.bigLoader);

                                      I hope it works for good (smile). I bring this topic up again if it starts giving me trouble.
                                      thanks for all your hard work. I don't get it. I'm stumped but it just started working.
                                      • 16. Re: PreLoader causing component problem
                                        crazyjoemilan Level 2
                                        haha, scoping some days is just terrible for me, I'm glad it panned out for you, and I'm sure if we took it apart we could find the difference, but come on, thats just crazy talk.