9 Replies Latest reply on Mar 26, 2008 9:48 AM by Rothrock

    what's is wrong with this code?

    renatohonjo
      If the first movie is not loaded, I will load the same movie from another server....
      Any clues?
        • 1. Re: what's is wrong with this code?
          kglad Adobe Community Professional & MVP
          1. _root0 and _root3 make no sense

          2. you're removing your listener before it hears anything.
          • 2. what's is wrong with this code?
            renatohonjo Level 1
            Hi, thanks for your reply.

            1. I don't have any clue of "_root" really means (someone in charge of that developed it). I just know that this code works FINE when the two url are found.
            2. My job is to develop a way to redirect the http request when the first and only url ( http://www.server.com/swf/fundo1.swf) is not found.

            Sorry about my english. Did I made myself clear?
            • 3. Re: what's is wrong with this code?
              Rothrock Level 5
              1. Well if it works it is really only a matter of luck. It really should be looked into because it doesn't make sense and is likely to break in the future. If they mean _level0, it generally isn't a good idea to replace the content in _level0 with external content. If they mean a movie called _root0 it isn't a good idea to give something a name like that.

              2. If you want different things to happen upon the load of different assets you've either goto use different MovieClipLoaders or inside the event handlers have some conditional code that will take the correct case. Like kglad said, you are using removeListener before there is any chance of having an event occur, so there is no way for your function to get called. You can't removeListener and still be listening.
              • 4. Re: what's is wrong with this code?
                renatohonjo Level 1
                Anyway, if the first part it's working it's fine for me. No problem.
                So, why this ain't working?
                • 5. Re: what's is wrong with this code?
                  renatohonjo Level 1
                  Does anyone have a sample code?
                  • 6. Re: what's is wrong with this code?
                    renatohonjo Level 1
                    This ain't working to. Is it correct?
                    • 7. Re: what's is wrong with this code?
                      Rothrock Level 5
                      The first example looks like it should work -- maybe, except there is no way for the loader to tell if the problem is with the first or the second loadClip. There might be problems with having the swfs come from two different domains. It would probably be best to test this locally until you get it woring, before you actually try and get it working cross-domain.

                      The second won't work because you've got loadListener.loadListener. I don't know what that is about.

                      When you said the don't work, how exactly don't they work?

                      Additionally, you might want to add so trace statements just to see what is getting called and what isn't. So inside the onLoadError handler (just before or after the replacement loadClip, add something like this:

                      trace("Loading "+target_mc+" failed. Loading replacement swf.")

                      Try those things out.
                      • 8. Re: what's is wrong with this code?
                        renatohonjo Level 1
                        I worked! But my is doesn't fit in the frame...
                        How can I resize my frame?
                        • 9. Re: what's is wrong with this code?
                          Rothrock Level 5
                          Welll... there are a few problems with that. You can't resize until you've loaded the content. So you need to have an onLoadInit event handler. Something like:

                          loadListener.onLoadInit=function(target:MovieClip){
                          trace([target._width,target._height])
                          }

                          The problem is that you are loading external swfs and their width and height can change. So if the first frame of the clip is blank or has a small box or something, it will give a small number and then in subsequent frames it will be larger.

                          If you know that, for example, it just needs to come down to 90% you can just set the _x/yscale. But if it can vary you will need to come up with a clever solution.