11 Replies Latest reply on Jun 9, 2008 7:58 AM by kglad

    onLoadError help please

    Bob Pierce Level 1
      In the response to an onLoadError during a sequence of loadClip(targetSWF, targetMC) calls I want to replace the targetMC with a default symbol from the library using attachMovie. Because I want the attached clip to replace targetMC I store its name and parent before deleting it. The code below seems simple enough but newTarget traces undefined, while the other traces are fine. I've checked the symbol id etc in a simple version of the attachMovie statement that doesn't use the mc from the onLoadError event and it works ok. Is there a reason why this can't be done?

        • 1. Re: onLoadError help please
          kglad Adobe Community Professional & MVP
          don't remove it. just use it as the attach target.
          • 2. Re: onLoadError help please
            Bob Pierce Level 1
            Thanks kglad, but I made that change and newTarget is still undefined. Anyway won't this give me a child clip of the existing target_mc rather than replacing it as I want?
            • 3. Re: onLoadError help please
              kglad Adobe Community Professional & MVP
              yes, it will give you a child or target_mc. if you don't want a child, then remove it and create a new movieclip to use as the attach target.
              • 4. Re: onLoadError help please
                Bob Pierce Level 1
                Perhaps I'm not clear what you mean by "the attach target": I have parentMC with a child of targetMC. I call loadClip(targetSWF, targetMC) which, when it succeeds, replaces the contents of targetMC (actually an empty mc) with that in targetSWF but leaves the name, depth etc as before. If it fails I want to put something in place of targetMC that can be referenced successfully by the existing code. My solution (if it worked) is to delete targetMC and use parentMC.attachMovie(defaultSymbol, targetMCname, depth). I am assuming that the attach target here is parentMC so I'm a little puzzled by your suggestion to create a new movieclip to use as the attach target. Surely the target must be parentMC in order to replace targetMC?
                • 6. Re: onLoadError help please
                  Bob Pierce Level 1
                  Sorry, kglad, but collecting and re-using the porperties of targetMC is not the problem. That aspect aside, my original code sample matches yours except that where I use attachMovie(), you use createEmptyMovieClip() which just replaces targetMC with a duplicate. I use attachMovie() because I want to replace targetMC with a library symbol as a substitute for the swf which has failed to load. In this context attachMovie() fails and I was looking for help in understanding why. I've done some testing which showed that my code works, but only if the attachMovie() target is _root. The parent of targetMC is a loaded .swf and that rang a small bell about something I'd read in Colin Moock book. I found the reference which explains that "once a clip has an external .swf file loaded into it, that clip can no longer bear attached movies from the library from which it originated."

                  • 7. Re: onLoadError help please
                    kglad Adobe Community Professional & MVP
                    targetParent is a loadMovie or loadClip target movieclip?
                    • 8. Re: onLoadError help please
                      Bob Pierce Level 1
                      The absolute path to targetMC, with the actual mc names is of this form:
                      _level0.main_mc.tray_5_mc.pane_1_mc
                      where,
                      main_mc is a swf loaded via loadClip()
                      tray_*_mc is created by createEmptyMovieClip()
                      pane_*_mc is created by createEmptyMovieClip(), then replaced by loadClip() with a .swf

                      • 9. Re: onLoadError help please
                        kglad Adobe Community Professional & MVP
                        then you have to fake the attachment. the most elementary way of doing that is to route all updates of main_mc through a function that updates the fake attachment.
                        • 10. Re: onLoadError help please
                          Bob Pierce Level 1
                          Thanks for that kglad. It won't surprise you learn that I don't know what a fake attachment is. However, it would probably involve a more fundamental change to my loading sequence than the solution I've decided upon. Instead of attaching a symbol from the library I will use loadClip() to load a .swf of the default mc. It won't happen often so the extra time is no problem. Thanks for your time on this.
                          • 11. Re: onLoadError help please
                            kglad Adobe Community Professional & MVP
                            you're welcome.

                            p.s. you can preload your fade attachment and then there won't be any perceptible delay.