32 Replies Latest reply on Nov 17, 2007 7:13 PM by kglad

    How to make several Check boxes interact to load a movie

    kebat
      Hello,
      I have a very complicated doubt. I have a document called “selection” with 15 check boxes.

      The check boxes are divided into groups. The first group is “category” and has 4 check boxes named “eco”, “conf”, “spor” and “ultr”, the second group is “makers” and has 4 check boxes named “bridge”, “dun”, “cont” and “fire”, the third group is “velocity code” and has 4 check boxes named “j”, “k”, “l” and “m”, finally the fourth group is “Run Flat” and has 3 check boxes named “yes”, “no” and “just” and I have a submit button.
      I have also a “main” document that has 20 holders called “holder1”, “holder2”, and so on…

      I would like to know if there is a way of, when I click the submit button if, for example, the check boxes “eco” and “conf” of the first group, the check boxes “bridge” and “fire” of the second group, the check boxes “j” and “m” of the third group and the check box “just” of the fourth group are selected, then, the movie “eco_bridge_j_just.swf” is loaded to holder1, the movie “eco_bridge_m_just.swf” is loaded to holder2, the movie “eco_fire_j_just.swf” is loaded to holder3, the movie “conf_fire_m_just.swf” is loaded to holder4 and so on…

      Please tell me that it is possible and the best way of doing it. My Action Script is not very good so I thank everyone who can help me.
        • 1. Re: How to make several Check boxes interact to load a movie
          kglad Adobe Community Professional & MVP
          well, you can't check more than one radio button in a group. but once you straighten that out, yes you can do what you want.

          you can

          1 use each radiogroups' selection property to read the instance name of the selected radiobutton in each group.

          2. concatenate those names to form the name of your swf.

          3. do whatever you like with that name including loading into a target movieclip.
          • 2. Re: How to make several Check boxes interact to load a movie
            kebat Level 1
            Hello! Here I am, annoying you again.
            Do you remember the help you gave me with a combo box?

            I am using check boxes and not radio buttons. I believe that is the only way of having more than one check box selected.
            When I said that I have four groups of check boxes I didn't realized that There is a way of grouping them. (Did I say that my English sucks?) What I mean is that I have four groups in the design and not in any other way because I don't know how. I'm not sure if I'm explaining myself properly.
            My other problem is that My action Script is very, very, very bad.

            Please help me again!
            • 3. Re: How to make several Check boxes interact to load a movie
              kglad Adobe Community Professional & MVP
              with checkboxes you'll need to loop through them all to find which are selected (using the selected property of checkboxes). to do that you should list you checkbox instance names in an array.

              because you're using checkboxes it will be probably be possible for users to chose combinations that do not correspond to a valid file name. you'll need to do something about that.
              • 4. Re: How to make several Check boxes interact to load a movie
                kebat Level 1
                The instance name of my check boxes are the ones I wrote in the first message.

                If I could write a code that find witch check boxes are selected and arrange a way to start for the first group (if there is no check box selected it will assume that all of them are selected) and in the loadMovie write the name of the fist check box selected, go to the second group to see the name of the first check box of the 2nd group and write it in the loadMovie, go to the first selected check box of the third group and write it in the loadMovie, the same with the forth group and then return to the first group to see the second check box selected and so on until the LoadMovie has a series of other combinations.

                I believe that is the only way of doing this. I have to use check boxes because in the first, second and third group users can have more than one choice. Only in the fourth group I could use radio buttons.

                I am prepared to do the amount of documents necessary for this to work. I can't think of an easy way of doing what I want. I'm going crazy all over again.

                Thank you for helping me.
                • 5. Re: How to make several Check boxes interact to load a movie
                  kglad Adobe Community Professional & MVP
                  you mean to say if someone checks 2 boxes in the first group, 3 boxes in the 2nd group, 2 boxes in the 3rd group and 2 boxes in the 4th group, you want to download 24 swfs?
                  • 6. Re: How to make several Check boxes interact to load a movie
                    kebat Level 1
                    Yes! That's what I meant. But in the fourth group I want the user to choose just one of the 3 check boxes.
                    The swf's are very small and I want the "main" document to be loaded in level 0 and the swf's to be loaded in the targets that I've created in the "main" document.

                    I know it looks crazy but I have no idea of another way of doing it. Please help me!
                    • 7. Re: How to make several Check boxes interact to load a movie
                      kglad Adobe Community Professional & MVP
                      then create 4 arrays with each array containing the checkbox instance names of the 4 groups:

                      • 8. How to make several Check boxes interact to load a movie
                        kebat Level 1
                        I've tried to use your code but nothing happened. I added the third and fourth group but when I test my movie the output panel keeps saying: "submitBtn.onPress=function(){ Statement block must be terminated by '}'" .
                        I've already told you that my action script is very bad. I've tried to insert the } everywhere I thought it belonged and now I have a "no errors" script but it still doesn't work.
                        I was thinking that since my fourth group has only 3 check boxes and I wanted users to pick only one, to substitute the check boxes for radio buttons but I don't know if I'm complicating too much. The search for the results must include the fourth group.
                        I know this is very complicated but is there any simple way of doing what I want?

                        • 9. Re: How to make several Check boxes interact to load a movie
                          kglad Adobe Community Professional & MVP
                          there should be 3 } at the end of that code instead of two.

                          copy and paste your code using the attach code option.
                          • 10. Re: How to make several Check boxes interact to load a movie
                            kebat Level 1
                            The last time I've tried to simplify my doubts I ended up confusing you. I'm so sorry for that. As you will see, what I'm trying to do is a little bit more complicated.

                            I want to change the fourth group. I want to use radio buttons instead of check boxes but just for the fourth group. Does the code remains the same?
                            I also wanted that, when I press the submit button, the movie "main" was loaded to level 0 (because it's in the main document that I have my targets) and the swf's were loaded to the targets in the main document. Is it possible?

                            Thank you for all the help you are giving me!
                            This is my code
                            • 12. How to make several Check boxes interact to load a movie
                              kebat Level 1
                              Thank you so much! It's already loading the swf's.
                              You didn't tell me if the code will remain the same if I use radio buttons instead of check boxes in the fourth group.

                              And is there a way of loading the "main" document in level0 and the load the swf's to the targets in the "main" document, instead of loading them to an empty movie clip? The problem of load the swf's to an empty movie clip is that the swf's are loaded on top of the things that are already in that page (in top of the check boxes) and if more than one swf is loaded, they are loaded one in top of the other.
                              Another thing that I wanted to ask you is if there is a way of changing the script to assume that all the check boxes of one group are selected if the user selects none. I need it because the the swf's are loaded only if, at least, one of the check boxes of each group is selected.

                              Thank you!
                              • 13. Re: How to make several Check boxes interact to load a movie
                                kglad Adobe Community Professional & MVP
                                radiobuttons should work, too.

                                the main document is _level0. anything you load into _level0 becomes the main document and anything that existed prior to loading into _level0, is unloaded.

                                check the help files: as2 component language/checkbox for all its methods and properties. you'll see you can detect if they are selected and not you can for a string of their names or data to suit your needs.
                                • 14. Re: How to make several Check boxes interact to load a movie
                                  kglad Adobe Community Professional & MVP
                                  radiobuttons should work, too.

                                  the main document is _level0. anything you load into _level0 becomes the main document and anything that existed prior to loading into _level0, is unloaded.

                                  check the help files: as2 component language/checkbox for all its methods and properties. you'll see you can detect if they are selected and, if not, you can for a string of their names or data to suit your needs.
                                  • 15. Re: How to make several Check boxes interact to load a movie
                                    kebat Level 1
                                    Thank you for all your help.
                                    Can you just tell me how can I load the swf's to targets "alvo1", "alvo2", etc ?
                                    I'm trying to combine (in every way possible) the combo box script with this one but I can't get it right.
                                    The combo box script that I have is this:

                                    for (var i = 0; i<e.target.selectedItem.data.length; i++) {
                                    _level0["alvo"+(i+1)].loadMovie(e.target.selectedItem.data );
                                    trace(_level0["alvo"+(i+1)]+" : "+e.target.selectedItem.data
                                    );

                                    But once I change the:
                                    tl["mc_"+i1+"_"+i2+"_"+i3+"_"+i4].loadMovie(gp1A[i1]._name+"_"+gp2A[i2]._name+"_"+gp3A[i3] ._name+"_"+gp4A[i4]._name+".swf");

                                    the script no longer works. Thank you for everything!
                                    • 16. Re: How to make several Check boxes interact to load a movie
                                      kglad Adobe Community Professional & MVP
                                      use the attach code option to display code in this forum.

                                      does that trace reveal the external files you want to load and show those target movieclips exist?
                                      • 17. How to make several Check boxes interact to load a movie
                                        kebat Level 1
                                        That code was a little bit different because it belonged to a combo box (in _level3) that was meant to load the swf's in the targets located in _level0.
                                        When I test this movie (the combo box in _level3), the output panel don't show any trace. In the "main" document (my _level0) I also have a - trace(alvo1); - and when I test my movie in the output panel 2 traces appear.
                                        I now have a lot of targets in the same document of the check boxes. The targets exist and are named "alvo1", "alvo2" and so on.

                                        I'm not sure if I'm explaining myself properly. My English is almost as bad as my action script. I'm sorry for that!
                                        • 18. Re: How to make several Check boxes interact to load a movie
                                          kglad Adobe Community Professional & MVP
                                          if you don't see anything from a trace() function, it means that portion of your code didn't execute. ie, your for-loop didn't execute and your loadMovie() methods didn't execute.
                                          • 19. How to make several Check boxes interact to load a movie
                                            kebat Level 1
                                            I thought everything was working perfectly. I thought the output panel didn't show the trace because the trace was to a target in another document. I forgot to tell you that, when I test my "main" document, in the output panel 2 traces appear (trace alvo1 and trace alvo1), even though I only have one trace in that document.
                                            If I select a label in the combo box and the swf's that are supposed to be loaded are not in that folder the output panel shows: undefined : 205-55 16.swf undefined : 225-50 16.swf undefined : 115-85 18.swf.
                                            Isn't it right? Is dis going to work? Can I do something to make the swf's that are supposed to be loaded from the selection of the check boxes to be loaded into my targets in this document? Should I panic now?
                                            • 20. Re: How to make several Check boxes interact to load a movie
                                              kglad Adobe Community Professional & MVP
                                              you don't need to panic. but i don't know what you're doing.

                                              use the trace() function to pinpoint problems. if something is undefined, that's a problem. fix it.

                                              if something is defined but the trace output isn't what you expect, fix it.

                                              you do need to get organized and methodically debug your project. when you pinpoint a problem and don't know how to resolve it, that's when posting to this forum is most likely to be helpful.
                                              • 21. Re: How to make several Check boxes interact to load a movie
                                                kebat Level 1
                                                You're right and I'm sorry. I'm a little bit out of my league. My problem is that there are absolutely no tutorials that explain what I need.
                                                I've already fixed most of my problems. The one that I can't find a way to solve is a way of making my swf's be loaded into targets that already exist. In the script you wrote, every time that I click the submit button it creates a new movie clip and if I'm loading more than one swf, they load one in top of the other. I need them to be loaded into targets because I can control their exact position.
                                                I don't mean to be annoying but can you help me with this one thing?
                                                Thank you!
                                                • 22. Re: How to make several Check boxes interact to load a movie
                                                  kglad Adobe Community Professional & MVP
                                                  what are the path/names of your targets from the timeline that contains your loadMovie() statements?

                                                  put a trace() function near those loadMovie() statements to ensure you have those paths/names correctly stated.
                                                  • 23. Re: How to make several Check boxes interact to load a movie
                                                    kebat Level 1
                                                    The names of my targets are "alvo1", "alvo2", "alvo3" and so on.
                                                    I've already tried to do that. The trace is working. It recognizes the target but once I change the lines of code (tl var) that are meant to create a new movie clip to load the swf's, the code doesn't work, even though it has no errors.
                                                    I've tried to combine in every way possible the scripts that I have in order to do the swf's load in my targets. This time I thought it would be easier because my targets are in the same document than my check boxes.
                                                    Please help me! Thank you for everything.
                                                    • 24. Re: How to make several Check boxes interact to load a movie
                                                      kglad Adobe Community Professional & MVP
                                                      if your trace functions reveal that your target movieclips exist either, you are loading ok and you just don't see it or the strings to the external swfs are incorrect. use a trace function on those file names. and case counts when files are on a server.
                                                      • 25. Re: How to make several Check boxes interact to load a movie
                                                        kebat Level 1
                                                        My targets movieclips exist and are in the same timeline as my check boxes. The problem is that I've tried everything I know and I can't get the code to work. The output panel accuses no errors but as soon as I change the "create empty movieclip" in the code it no longer works. None of the swfs is loaded.
                                                        I've already checked and rechecked my file names and my targets and pretty much everything.
                                                        I don't know what else can I do. I really need to make it work in my targets otherwise the swfs will be loaded one in top of the other.
                                                        • 26. Re: How to make several Check boxes interact to load a movie
                                                          kglad Adobe Community Professional & MVP
                                                          copy and paste the loadMovie() code you use that fails. and use the attach code option.
                                                          • 27. Re: How to make several Check boxes interact to load a movie
                                                            kebat Level 1
                                                            Well, I'll send you the entire code.
                                                            I've manage to get myself a new problem. When I test my movie my trace don't show up. When I press the submit button the output panel shows "alvoNaN". My trace shouldn't be there, right? My targets are named "alvo1", "alvo2", etc. I know something is missing so please don't laugh.
                                                            • 28. Re: How to make several Check boxes interact to load a movie
                                                              kglad Adobe Community Professional & MVP
                                                              where's i defined? that's the problem.
                                                              • 29. Re: How to make several Check boxes interact to load a movie
                                                                kebat Level 1
                                                                Ok! How do I do that?
                                                                I've tried to add this "for(var i = 0;length; i++) {" after the other variables but it still don't work. The script as no errors but my trace isn't working. The output panel shows nothing. What am I doing wrong?
                                                                • 30. Re: How to make several Check boxes interact to load a movie
                                                                  kglad Adobe Community Professional & MVP
                                                                  you have to understand those 4 for-loops if you want your swfs to load into particular alvo movieclips. if you don't care where your swfs load you can probably use:

                                                                  • 31. Re: How to make several Check boxes interact to load a movie
                                                                    kebat Level 1
                                                                    As always: You are the best!
                                                                    Thank you so much! Everything is working perfectly! Thank you!
                                                                    • 32. Re: How to make several Check boxes interact to load a movie
                                                                      kglad Adobe Community Professional & MVP
                                                                      you're welcome.

                                                                      (and good luck!)