13 Replies Latest reply on Jun 22, 2009 2:11 PM by Sampad123

    Multiple rollout if state options required

    Sampad123

      I have navigation set up, where on rollover of each button 3 separate movieclips are affected. On release another movieclip is effected and a swf is loaded. Fine so far - here is the code (where the first mclip is where the buttons are located and the command goes to a frame in that mclip, the 2nd mclip is called copy and the 3rd is called date)(the mclip effected on release is called overs):-

       

      on (rollOver) {
          gotoAndStop('icups');
          copy.gotoAndStop('icups');
          date.gotoAndStop('icups');
      }
      on (release) {
          loadMovie("icups.swf",_root.loadclip);
          overs.gotoAndStop('icups');

       

      }

       

      Now on rollout i want nothing to change if the onrelease state has been activated ie the button is on and the swf is loaded. If the button has not been activated (clicked) then on rollout i want all the mclips affected by the rollover to revert to their off states.

       

      I have set up a variable within the mclip 'overs' that makes the on state for each button true. So, if the button has not been clicked it is false all the mclips go to their off states, but if it has been clicked, the else state tells the mclips to stay on (i realise i could have left the else state empty here - you will see why i have put the goto commands in when i illustrate my problem further).

       

      on (rollOut) {
          if (_root.icups == false) {
          gotoAndStop('off');
          copy.gotoAndStop('off');
          date.gotoAndStop('off');

       

      }
          else {
          copy.gotoAndStop('icups');
          date.gotoAndStop('icups');
          }
      }

       

      The problem i have is that I need options for what happens to the mclips for each of my navigation buttons. So that when you have one button on, you can rollover another and see its rollover states, but when you rollout of that other button it defaults back to the over state of the button that is on. The only way i could think of doing it was with the following code: (where cf and tactical are the other buttons i.e whatever button is on is the default state on the rollout)

       

      on (rollOut) {
          if (_root.icups == false) {
          gotoAndStop('on');
          copy.gotoAndStop('off');
          date.gotoAndStop('off');

       

      }
          else {
          copy.gotoAndStop('icups');
          date.gotoAndStop('icups');
          }
      }
      on (rollOut) {
          if (_root.cf == false) {
          gotoAndStop('on');
          copy.gotoAndStop('off');
          date.gotoAndStop('off');

       

      }
          else {
          copy.gotoAndStop('cf');
          date.gotoAndStop('cf');
          }
      }
      on (rollOut) {
          if (_root.tactical == false) {
          gotoAndStop('on');
          copy.gotoAndStop('off');
          date.gotoAndStop('off');

       

      }
          else {
          copy.gotoAndStop('tactical');
          date.gotoAndStop('tactical');
          }
      }

       

      People with a better knowledge of flash than me will recognise that only the last rollout command is picked up - so in this case rollout on all 3 buttons (when cf and icups are not on) revert back to the tactical rollover states of the mclips.

       

      The last time i put a problem on to this forum, i also spent a long time pasting my code and trying to describe my problem in detail, i then received an email from someone asking me what my problem was! Please only reply with questions based on what i've put here, if it doesn't make any sense to you then don't worry about it. If it does make sense to anyone out there tho, or if you have a better way of turning rollover states on and off, please dont' hestitate to get in touch with me. Thanks

        • 1. Re: Multiple rollout if state options required
          Sampad123 Level 1

          I will try and clarify my overall problem - when the button loads a movie the rollover states of instances 'copy' and 'date' should relate to that movie.

           

          If you rollover another button - the rollover state should change, to relate to the movie that this particular button will load,

          but when you rollout (and dont' click to load the associated movie),

          the rollover state should default back to that associated with the movie you just loaded (and the button that loaded it).

           

          So, if i put the onrollover states into the onrelease action instead i would not have this problem -

          as 'copy' and 'date' would not change once the movie was loaded.

          Only changing when another button is pressed and its associated movie loaded.


          In a nutshell, having the associated states of instances 'copy' and 'date' as rollovers means they can be changed when rolling over a different button,

          and i need them to revert back to the states associated with the loaded movie (on rollout of the different buttons).

           

          Obviously, if no movie is loaded then rolling out should turn instances of 'date' and 'copy' off.

           

          I hope this makes my problem a bit clearer.

          • 2. Re: Multiple rollout if state options required
            kglad Adobe Community Professional & MVP

            if your rollover/rollout states depend upon the most recently loaded swf, use a variable to point to that loaded swf and use that variable to determine your rollover/rollout states.

            • 3. Re: Multiple rollout if state options required
              Ned Murphy Adobe Community Professional & MVP

              What might help both you and folks trying to help would be to change your coding approach to not be using code on objects and have the code in the timeline using instance names.  At the moment, I'm confused because I can't easily tell how many buttons you have and how many clips you have and which are which in the names you keep mentioning.  You likely provided all those details, but (for me) trying to tie things together gets scattered.

               

              Give each button an instance name on the stage and assign onRollover, onRollOut, and onRelease functions to them instead of what you have now.  Doing that may help lead to an easier resolution... you may be able to create a function that manages the buttons and clips conditions instead of trying to spread/manage it across all of the objects.

              • 4. Re: Multiple rollout if state options required
                Sampad123 Level 1

                I already have the variables set up - on the mclip instance 'overs' - with the associated variable for each loaded swf called from there.

                This is working fine - i don't think reading the variable from somewhere else (the loaded swf) will make any difference.

                 

                on (release) {
                loadMovie("icups.swf",_root.loadclip);
                overs.gotoAndStop('icups');


                }

                on (rollOut) {
                if (_root.icups == false) {
                gotoAndStop('off');
                copy.gotoAndStop('off');
                date.gotoAndStop('off');


                }
                else {
                copy.gotoAndStop('icups');
                date.gotoAndStop('icups');
                }

                 

                I just need the rollout state on the buttons to read all the variables - so that the else state correctly recognises which movie is loaded (i.e which variable to listen to). Above is just one of the varables of course. That's the problem - how can i make the command rollout if sate read all the variables (i know how to do that bit) BUT then respond to each of them diff in the else state?? That's the problem.....

                • 5. Re: Multiple rollout if state options required
                  Sampad123 Level 1

                  Each button does have an instance name and an associated onrollover and on rollout and onrelase function - and each mclip has an instance name - please see my post again.
                  I have 3 buttons - 'icups', 'tactical' and 'cf'
                  talking to 3 movie clips  on rollover - called 'date', 'copy' and the mclip where the button itself resides. As well as loading a swf and talking to a mclip called 'overs' onRelease.
                  It's my onrollout that is the problem.
                  I've tried this - so each button calls the variable for the other 2 - but it doesn't work

                  on (rollOut) {
                      if (_root.icups == false, _root.cf == false, _root.tactical == false) {
                      gotoAndStop('on');
                      copy.gotoAndStop('off');
                      date.gotoAndStop('off');

                  }
                      else {
                         
                      }
                  }

                   

                  The else state doesn't know what to default to if any of the statements is not faulse (ie the associated swf is loaded)

                  I like the idea of a central function to control the rollout states on all 3 buttons based on the variables - no idea how i'd do that though

                  • 6. Re: Multiple rollout if state options required
                    kglad Adobe Community Professional & MVP

                    i don't see _root.icups defined and it's certainly not defined in your onRelease.

                     


                    btn.onRelease=function(){

                    loadMovie("icups.swf",_root.loadclip);
                    overs.gotoAndStop('icups');
                    loadedSWF="icups";
                    }

                    btn.onRollOut=function()) {

                    // i'm not sure exactly what you're trying to do but, this should get you close
                    gotoAndStop(loadedSWF');
                    copy.gotoAndStop(loadedSWF);
                    date.gotoAndStop(loadedSWF);
                    }

                    • 7. Re: Multiple rollout if state options required
                      Sampad123 Level 1

                      That code didn't work - lots of errors

                      I can send you the fla?

                      i'll make some dummy swf for you to load - i think its the only way 

                      you'll see what i mean

                      i know i'm not doing it right - its all to do with the buttons being 

                      in a mclip - the on state is a mess (in the overs mclip where the 

                      variable is coming from)

                       

                      do you want me to send you the fla?

                       

                       

                      Sam Padmore

                      M 07763560730

                      • 8. Re: Multiple rollout if state options required
                        Sampad123 Level 1

                        I think i'm looking at this the wrong way -

                        my navigation is based on a mclip - with each over/down state on a 

                        diff frame and blank buttons on a separate layer in that mclip

                        It does make the on state conflict with the rollout state -

                         

                         

                         

                         

                         

                        Sam Padmore

                        M 07763560730

                        • 9. Re: Multiple rollout if state options required
                          Sampad123 Level 1

                          var nav;

                          cf = false;

                          icups = false;

                          tactical = false;

                           

                           

                          those are my variables

                          and they are defined in the mclip overs on the frame of that name

                           

                          _root.icups = true

                           

                          i have traces on all of these variables and they are working.

                           

                          I see you are using a function here.

                           

                          i'll give it a try

                           

                           

                          I just need the rollover state to default back to the on state 

                          associated with the loaded swf when you rollout - of any button

                           

                           

                           

                           

                           

                          Sam Padmore

                          M 07763560730

                          • 10. Re: Multiple rollout if state options required
                            Sampad123 Level 1

                            var nav;
                            cf = false;
                            icups = false;
                            tactical = false;

                             


                            those are my variables
                            and they are defined in the mclip overs on the frame of that name

                             

                            _root.icups = true

                             

                            i have traces on all of these variables and they are working.

                             

                            I see you are using a function here.

                             

                            i'll give it a try

                             

                            I just need the rollover state to default back to the on state associated with the loaded swf when you rollout - of any button

                             

                             

                             

                            That code didn't work - lots of errors
                            I can send you the fla?
                            i'll make some dummy swf for you to load - i think its the only way you'll see what i mean
                            i know i'm not doing it right - its all to do with the buttons being in a mclip - the on state is a mess (in the overs mclip where the variable is coming from)

                            • 11. Re: Multiple rollout if state options required
                              Sampad123 Level 1

                              so, i worked it out myself - i needed to separate the mclips 'copy' and 'date' into individual mclips for each button. That way the commands based on the variables were not conflicting and it worked.

                              • 13. Re: Multiple rollout if state options required
                                Sampad123 Level 1

                                Hi

                                Hope you got my message - i had to separate the copy and date 

                                instances into one for each variable - that made it work.

                                Keeping them all in the on mclip was just confusing things.

                                Thanks for your help anyway.

                                 

                                Sam

                                 

                                Sam Padmore

                                M 07763560730