26 Replies Latest reply on Jul 15, 2008 10:53 AM by SuperJAG

    Help with Loadmovie

    kebat Level 1
      Hi!

      First, I would like you to forgive me for my poor English and thank the ones that will take time to understand my questions.

      I´m having a hard time to build a data base for a tire company Web site, but it's almost done. I'll do my best to explain my problem to you, and than I'll post the code...

      I have one SWF file with 10 targets named "alvo1", “alvo2”, “alvo3”, etc and several check boxes divided by groups.
      The first group has 4 check boxes named "economico”, “conforto”, “desportivo” and “ultra-desportivo” dividing the tires by their type (sport, confort, etc).
      The second group has 10 check boxes named “bridgestone”, “continental”, “dunlop”, “firestone”, “goodyear”, “mabor”, “michelin”, “pirelli”, “uniroyal”, and “yokohama” dividing the tyres by their brand.
      The third group has 13 check boxes named “l”, “m”, “n”, “p”, “q”, “r”, “s”, “t”, “h”, “v”, “w”, “y” and “zr” dividing the tires by their speed performance.
      The fourth and last group has 3 radio buttons named “sim”, “nao” and “sim2” (Yes, No, and Yes2) to include (or not) the tire results that have the "Run Flat Tire" technology.

      With A LOT of Kglad's help I've got a code that works the way I wanted. The code assumes that if no check box of a group is selected, all check boxes are selected, so all results are listed.

      Now comes the problem...

      I don't have files (results) for all possible combinations, so, for example, if I selected the check boxes that would load the files “economico_bridgestone_m_sim.swf”, “conforto_bridgestone_r_sim.swf” and “desportivo_bridgestone_t_sim.swf”, but if the second file does not exist, the space destined to the target "alvo2" will be empty and the blank space between the targets "alvo1" and "alvo3" will be huge.
      So, I would like to know how can I add a code that says that if the file that is supposed to be loaded in the target doesn't exist, load the next file that exists in that same target.

        • 1. Re: Help with Loadmovie
          kglad Adobe Community Professional & MVP
          if you use the moviecliploader class you can use its onLoadError method and detect load failures. then you could take action based on the target movieclip that caused the error (like shifting all the target movieclips that would be positioned after that target movieclip).
          • 2. Re: Help with Loadmovie
            kebat Level 1
            I have no idea on how to do that. Please help me... once again...

            How can I use the moviecliploader class to avoid the errors I'm having?

            I'm sorry but my ActionScript skills improved just a bit since the last time we spoke.
            • 3. Re: Help with Loadmovie
              kglad Adobe Community Professional & MVP
              to use the moviecliploader class you create an instance and you create a listener:

              • 4. Re: Help with Loadmovie
                kebat Level 1
                Thank's a lot for helping me!
                I really need to make this work.I'm sorry if what I'm about to ask will sound dumb.

                I don't understand the last part of the code. What is supposed to be "yourswf.swf, yourTargetMC"?
                I think I understand the rest of the code but How do I know what .swf will be loaded?
                It depends on the users choice. I have the same problem with the target. The number of the target depends on the user's choice.

                I've tried to "play" with the code, experiment a few combinations but I can't make any improvement. I'm sorry but my skills at Actionscript are very basic.
                • 5. Re: Help with Loadmovie
                  kglad Adobe Community Professional & MVP
                  yourswf.swf is the swf you want to load: economico_bridgestone_m_sim.swf, for example.

                  yourTargetMC is the target movieclip into which you want to load your swf.

                  those two things won't change when you use the moviecliploader class. instead of using

                  yourTargetMC.loadMovie("yourswf.swf");

                  like you currently use, you'll use:

                  mcl.loadClip("yourswf.swf",yourTargetMC);
                  • 6. Re: Help with Loadmovie
                    kebat Level 1
                    I have this code now, that I think that might solve the problem, but it contains errors. It doesn't load any movie and the output panel calls the movie "undifined_undifined_undifined_undifined.swf".

                    Could you help me correct the code? Thanks

                    • 7. Re: Help with Loadmovie
                      kglad Adobe Community Professional & MVP
                      what purpose does it serve to use that code instead of the code in your first message?
                      • 8. Re: Help with Loadmovie
                        kebat Level 1
                        quote:

                        Originally posted by: kglad
                        what purpose does it serve to use that code instead of the code in your first message?


                        Why are you always so difficult? :-)

                        You know that it's hard for me to fully understand the code and detect the errors. A friend of mine is trying to help me with the code, but he's also learning. We are in that early stage where we can read and understand ActionScript, but we are still unable to write the code correctly.

                        I think the last part of this second code I posted is "supposed" to validate the existence of the swf that will be loaded into the target. The problem is that I don't know where the errors begin.

                        When I select the check boxes that will load a swf that exists, the Flash output panel says that it was unable to load the movie "undifined_undifined_undifined_undifined.swf". When the swf doesn't exist the output panel says it was unable to load the correct file that was selected.

                        Please help me with this. My vacations starts as soon as I get this ready. So, you can see how important your help is to me. :-)
                        • 9. Re: Help with Loadmovie
                          kglad Adobe Community Professional & MVP
                          it just doesn't seem to move you closer to solving your problem and it doesn't look like it's an attempt to solve your problem.

                          and because you're now getting "undefined_undefined_undefined_undefined.swf", it looks like it's a step backwards. before you were generating the correct strings to load.
                          • 10. Re: Help with Loadmovie
                            kebat Level 1
                            I'm so lost...

                            It's very hard for me to explain my Flash problems in English (I'm Portuguese) while I'm still trying to understand some new code.

                            I really need you to help me take a step forward. Aren't there a couple of lines of code ready to make this work?

                            I don't know how to use the moviecliploader class suggestion you gave me, because the user can choose from a thousand possible combinations. In fact, there are about that number of swf's ready to be loaded with the results for each combination.

                            Thanks,
                            Sandra
                            • 11. Re: Help with Loadmovie
                              kglad Adobe Community Professional & MVP
                              try:

                              • 12. Re: Help with Loadmovie
                                kebat Level 1
                                Thank you Kglad but the problem still remains.
                                When the user choose a selection that loads a movie that don't exist the respective target is still blank and the next file that exists appears in the same target that it was supposed to if all the files existed.
                                • 13. Re: Help with Loadmovie
                                  kglad Adobe Community Professional & MVP
                                  do you see the commented line:

                                  // reposition your target movieclips here

                                  you must put some code there to reposition your target movieclips.
                                  • 14. Re: Help with Loadmovie
                                    kebat Level 1
                                    But the problem is that I don't know what target needs reposition. Once again, it depends on the user's choice.
                                    Unless there is a way of saying that if the movie that is supposed to be loaded don't exist, move all the targets that follow the one that would be blank a "x" number of pixels vertically.
                                    • 15. Re: Help with Loadmovie
                                      kglad Adobe Community Professional & MVP
                                      you should setup your application so you can track what movieclips you are going to attempt to load and where they will be positioned or use some logic so when there's a load-failure, you can determine which movieclips need to be repositioned and where they need to be positioned.
                                      • 16. Re: Help with Loadmovie
                                        kebat Level 1
                                        Do you mean setting up Flash to track all possible loads and load-failures and then code this possibilities for all possible targets? That's just you being mean to me, as you should know by now that it would take me years to do.

                                        Wouldn't it be easier to do something like I was suggesting in my last post - an automatic reposition of the "next" existing targets after each failure? Isn´t there a way of doing this?
                                        • 17. Re: Help with Loadmovie
                                          kglad Adobe Community Professional & MVP
                                          no, you wouldn't deal with all possible load combinations. you just need to track what's occurring when your loadClip() method executes.

                                          you must already have some method to determine where to position the next swf that loads, correct? how do you do that?
                                          • 18. Re: Help with Loadmovie
                                            kebat Level 1
                                            No. I don't have any method to determine their position. They just load into the existent targets I created ("alvo1", "alvo2", "alvo3", etc), with the nonexistent swfs occupying some middle targets, creating blank spaces. I don't know how to use the onLoadError function to determinate the position of the next swf.

                                            Is there a way to build a function that generates new targets automatically? I don't know how to build the code, but it would be great if this function could only create a new target if the file exists, if there is no error in the moviecliploader function.
                                            • 19. Re: Help with Loadmovie
                                              kglad Adobe Community Professional & MVP
                                              swfs only load (or attempt to load) when the submit button is pressed?
                                              • 20. Re: Help with Loadmovie
                                                kebat Level 1
                                                Yes. You can select all the check boxes you want and then you have to press the submit button to load the swfs.
                                                • 21. Re: Help with Loadmovie
                                                  kglad Adobe Community Professional & MVP
                                                  then try:

                                                  • 22. Re: Help with Loadmovie
                                                    kebat Level 1
                                                    Thanks for the new code, Kglad.

                                                    The problem with this code is that all the swfs are being loaded to the same target (alvo1), so, the only result we can see now is the last swf that exists.

                                                    I've tried to insert "i++;" in the blank line of the code to correct this problem and it did, but the blank spaces between the results showed up again.
                                                    • 23. Re: Help with Loadmovie
                                                      kglad Adobe Community Professional & MVP
                                                      i is incremented in onLoadInit(). you shouldn't change it elsewhere.

                                                      when the submit button is pressed, is one swf loaded? and then the next time it's pressed, another swf is loaded etc?
                                                      • 24. Re: Help with Loadmovie
                                                        kebat Level 1
                                                        When I make a selection of check boxes, the only result presented is the last combination that exists.

                                                        If the choice includes 2 possible results - one exists, the other doesn't - it only shows the result that exists if it is the last one. Nothing appears if the last combination loads a file that doesn't exist.

                                                        Tell me if I'm confusing you. My English sucks.
                                                        • 25. Re: Help with Loadmovie
                                                          kglad Adobe Community Professional & MVP
                                                          that complicates things. you could change your for-loops so they don't try and load multiple swfs almost simultaneously. that would solve the problem. ie, run through those loops by calling your submit button function repeatedly from the onLoadInit() where your for-loop variables are incremented.

                                                          or you could store (in an array) all the target movieclips into which you're attempting to load those swfs. and then reposition those movieclips based on any onLoadError() methods.

                                                          but neither alternative is particularly straight-forward and i can't think of a simpler way to proceed. if you can understand how to start on either of those alternatives, i'll continue to help you in this forum.

                                                          otherwise, someone else may be able to help you or you can hire me to solve the problem.
                                                          • 26. Re: Help with Loadmovie
                                                            SuperJAG
                                                            Try this.