26 Replies Latest reply on Apr 11, 2007 11:29 PM by kglad

    external SWF problems

    jessem1985
      i have a few SWF files loading into the main SWF. I am using a blank movie clip to load the external SWFs.

      loadMovie("photos-color.swf", "color");

      That is actionscript I use to load the external SWF into the main SWF.

      I go to one page on my site, download the external SWF, then go to another page and when I go back to the first page, it reloads the SWF again. Just a pain in the ***.

      What do I have to add to that to tell the file not to reload once it has already been loaded?

      I have been searching all over and asking around and haven't found any answers. I've looked into listeners, is that the right direction at least?

      Thanks in advance for any help.
      jesse
        • 1. Re: external SWF problems
          kglad Adobe Community Professional & MVP
          anytime you have code that you want to execute once:



          • 2. Re: external SWF problems
            jessem1985 Level 1
            sounds logical but for some reason it didnt work.

            any other suggestions?
            • 3. Re: external SWF problems
              kglad Adobe Community Professional & MVP
              then one of us made an error.

              i don't see a typo in the code i gave. copy and paste the code i gave and make sure alreadyExecuted is the same in both locations. eg, copy it from one location and paste it to the other.
              • 4. Re: external SWF problems
                jessem1985 Level 1
                yeah its not working. i copied and pasted exactly what you put...

                if(!alreadyExecuted){
                loadMovie("photos-color.swf", "color");
                alreadyExecuted=true;
                }

                • 5. Re: external SWF problems
                  jessem1985 Level 1
                  am i supposed to add any script to the external SWFas well?
                  • 6. Re: external SWF problems
                    kglad Adobe Community Professional & MVP
                    no script is needed for the external swf.

                    what makes you think that's executing more than once? have you added a trace() function to see if the trace is executing more than once?
                    • 7. Re: external SWF problems
                      jessem1985 Level 1
                      well the file downloads completely and shows 100% then the content.

                      if i go to another area of my website and go back to the previous area, it reloads again. showing the loading bar and everything as if it were the first time i visited it.
                      • 8. external SWF problems
                        jessem1985 Level 1
                        code for external SWF loading bar

                        frame 1...

                        bytes_loaded = Math.round(this.getBytesLoaded());
                        bytes_total = Math.round(this.getBytesTotal());
                        getPercent = bytes_loaded/bytes_total;
                        this.loadBar._width = getPercent*200;
                        this.loadText = Math.round(getPercent*100);
                        if (bytes_loaded == bytes_total) {
                        this.gotoAndPlay(3);
                        }

                        frame 2...

                        this.gotoAndPlay(1);
                        • 9. external SWF problems
                          Greg Dove Level 4
                          You said: " go to one page on my site, download the external SWF, then go to another page and when I go back to the first page, it reloads the SWF again. "

                          Can you please clarify: are you navigating to another page and then coming back to a page with flash in it... and you're concerned that it reloads all the subclips? If so that's normal behaviour. It might reload subclips faster next time if they're in the browser cache, but it should behave like you just arrived at the page for the first time. You could save some information about the state with a local sharedObject or via server scripting if you want it to behave differently next time. Or you could use frames in the browser maybe.
                          • 10. Re: external SWF problems
                            jessem1985 Level 1
                            i only have my main movie and 2 external SWFs right now. all in flash.

                            each page on my site is a different scene in the .FLV.

                            and yes, i am concerned that the external SWFs are reloaded whenever i revisit that part of my main movie.
                            • 11. Re: external SWF problems
                              jessem1985 Level 1
                              if thats normal behavior, is there another way i can do this instead so it doesnt do that?

                              they are big files with photos in them and i dont want people to have to wait everytime after the first photo is loaded.

                              maybe a loading bar for each photo would be easier? might be even more of a pain for me though
                              • 12. Re: external SWF problems
                                Greg Dove Level 4
                                Sorry - just to be absolutely clear: when you say goto one page on your site for 'page' you are not referring to another html page, so its an all-flash site?
                                • 13. Re: external SWF problems
                                  jessem1985 Level 1
                                  yeah that is correct. sorry for the confusion.

                                  i am just viewing another scene on the site.
                                  • 14. Re: external SWF problems
                                    jessem1985 Level 1
                                    does anyone have any idea?
                                    • 15. Re: external SWF problems
                                      Greg Dove Level 4
                                      Please ignore my previous comments then - I thought you were talking about html 'pages'. You should then be able to prevent the reloading action... in the way that kglad described. From the symptoms it seems as if you might be mistakenly reloading in your original loader swf (back into the main timeline), which would over-write the alreadyExecuted boolean value. But its a wild guess... what you need to do is possible though.
                                      • 16. Re: external SWF problems
                                        jessem1985 Level 1
                                        ok that makes sense.

                                        but is there some coding i can put into the external SWF along with the loading bar script to say "if already downloaded 100%, do not retry."

                                        that seems like the logical step but i am newer to the scripting.
                                        • 17. Re: external SWF problems
                                          kglad Adobe Community Professional & MVP
                                          the code i gave just prevents the loadMovie() statement from executing. if you have other things you want to NOT happen (like having a preloader display) you need to also code for that.
                                          • 18. Re: external SWF problems
                                            jessem1985 Level 1
                                            well i want the preloader to display for the first time it downloads. but if i return to the same page, i want the content to display right away w/o downloading again.
                                            • 19. Re: external SWF problems
                                              kglad Adobe Community Professional & MVP
                                              it won't download again with the code i gave unless you have another loadMovie() statement located somewhere other than within that if-statement. but you may see your preloader display unless you also encode for it to be removed or not visible.
                                              • 20. external SWF problems
                                                jessem1985 Level 1
                                                ok so this is what i have.

                                                SCENES- (the dashed are the sub-categories)
                                                home
                                                design
                                                -graphic
                                                -web
                                                -type
                                                -drawings
                                                photos
                                                -color
                                                -b/w
                                                links

                                                in the COLOR scene, i have an animation that drops down and shows the area where the photos will load. in that movie clip of the dropdown area, i have the script that calls for the external SWF.

                                                loadMovie("photos-color.swf", "color");

                                                then it loads the movie and shows the clip of the pictures and works fine for what i want it to do.

                                                but if i click on B/W, then return to COLOR, the whole downloading starts again.

                                                i hope that explains it better.

                                                All i really want to have happen is to have the file download the first time and when revisited, just open up as if it were just placed there.

                                                I am hoping explaining the layout might help.
                                                • 21. external SWF problems
                                                  jessem1985 Level 1
                                                  can i add an if/then statement to the external that says "if loaded, dont load again?"
                                                  • 22. external SWF problems
                                                    Greg Dove Level 4
                                                    What I think is that clip hierachy for "color" may not exist on the timeline outside the color scene... if so its erased from memory (along with the alreadyLoaded logic). You would need to have it visible on the timeline throughout your movie, and set its ._visible property to false when you leave the color scene and true when you return.

                                                    I don't use scenes in flash, so i don't know how easy this is to do sorry.
                                                    • 23. Re: external SWF problems
                                                      jessem1985 Level 1
                                                      ok. so how would i write that out? im not so good at scripting just yet.

                                                      if(in scene color)
                                                      color._visible = true
                                                      if(not in scene color)
                                                      color._visible = false

                                                      something like that?
                                                      • 24. Re: external SWF problems
                                                        Greg Dove Level 4
                                                        No, you would probably do it at the same time you navigate to or away from the color section - in your buttons code or whatever navigation you have. But you have to have some way to make sure the color is present throughout the whole movie. I don't know how to do that with scenes
                                                        • 25. external SWF problems
                                                          jessem1985 Level 1
                                                          ok. well thanks for the help.

                                                          i will try that, but im the meantime, does anyone else have any suggestions?
                                                          • 26. Re: external SWF problems
                                                            kglad Adobe Community Professional & MVP
                                                            if your color moviecip doesn't continue to exist after leaving the scene that contains it, you'll need to re-create it and you'll need to re-load photos-color.swf.

                                                            if your color movieclip continues to exist, you don't need to do anything to make it reappear with its previously downloaded content except undo whatever you did to make it not visible after leaving the scene (if you made it not visible).