13 Replies Latest reply on Feb 5, 2010 4:40 PM by Ned Murphy

    Help Newbie With Company Website Idea

    Meb Moon Level 1

      Hi Everyone,

       

      I'm totally going to embarrass myself with my lack of actionscript knowledge... but, I hope someone can at least point me in the right direction.

       

      Here's what I'm attempting to do:

       

      I'm designing a flash site that has 5 buttons, each corresponding to a different company. When a button is pressed, the logo for that company will appear in the body of the site along with a brief company description. So far, that's all very easy I know. But, here's where it gets complicated (at least, for me):

       

      I've set up shape tweens (25 to be exact) so that every logo can "tween" into any of the other logos. The goal is to have it so that when you click on one of the company's buttons, the logo will shape tween from the current logo displayed to the logo for the company button you clicked. Make sense? I hope so.

       

      When a button is pressed, the script basically needs to find out what logo is currently displayed, so that it can know what shape tween movieclip to play.

       

      I've set up all the tweens on the timeline with Frame Labels: logo1ToLogo2, Logo1ToLogo3 and so forth. And then Logo2ToLogo1, Logo2ToLogo3 and so forth...

       

      Can somebody get me started? It would be very much appreciated!

       

      Thanks.

       

      Meb

        • 1. Re: Help Newbie With Company Website Idea
          Ned Murphy Adobe Community Professional & MVP

          One thing you will probably want to do first is to create a function that will disable/enable your buttons, so that you can inhibit anyone from using them during a transition.

           

          For the selection of which tween to choose, you'll need to establish a variable to keep track of which logo is currently being displayed.  The value that variable holds will be a string identifying the logo... "Logo1", "Logo2", etc  Let's say you name that variable "currentLogo"

           

          When you click a button, the button code will use a gotoAndPlay call that incorporates the currentLogo variable with the logo associated with the button...

           

          gotoAndPlay(currentLogo+"ToLogo#");

           

          where you put the number of the intended logo in place of #.  Following that line you'll want to assign the new currentLogo value followed by a call to the function for disabling of the buttons.  The call for enabling of the buttons can be done at the end of each of your tweens.

          • 2. Re: Help Newbie With Company Website Idea
            Meb Moon Level 1

            Hi Ned. 

             

            I just want to thank you for your helpful and clear answer.  Unfortunately, I haven't had time to work on this more, but plan to this weekend.  I'll let you know how it turns out.  I'll have to study some of the things you mentioned, but at least you pointed me in the right direction, which will be extremely helpful. 

             

            Thanks again!   

             

            Meb

            • 3. Re: Help Newbie With Company Website Idea
              Meb Moon Level 1

              Hi again Ned,

               

              Thanks again for your help.

               

              I'm still confused I'm afraid.

               

              So, let's say I have all my logo transitions on my timeline. (Note: I will need 5 transitions for EACH logo, so that the logo will have the ability to tween from any of the other logos.)  How would I name my Frame Labels in order to work with your idea?  What's confusing me is that I will have 5 transitions ALL ending on the same logo.  For example, just for Logo1, I'll need the following transitions:  logo5ToLogo1, logo4ToLogo1, logo3ToLogo1, logo2ToLogo1 and logo1ToLogo1. 

               

              Argh.... why can't I get my head around this?

               

              Thanks again,

               

              Meb 

              • 4. Re: Help Newbie With Company Website Idea
                Ned Murphy Adobe Community Professional & MVP

                I really don't want to repeat myself, so you'll need to reread what I offered earlier, but I'll give an example this time to add to it.  I don't know why you need 5 for each as it doesn't make sense to tween the same logo into itself but having it will be supported by the example.  In any case, each tween that you create you will assign a frame label to the beginning of that indicates which transition is involves.  For the example below, the frame label will be "logo1ToLogo2"...

                 

                So let's say Logo1 is initially displayed.  The variable I mentioned earlier is already assigned a value = "logo1" at the start.  So you click the button for Logo2, which you assign an instance name of "btn2", and it has the following code assigned to it on the timeline (not on the button)...

                 

                btn2.onRelease = function(){

                     disable_enable_btns();

                     gotoAndPlay(currentLogo+"ToLogo2");

                     currentLogo = "logo2";

                }

                 

                Each button will have the same code except number (2 in this example) will change to agree with the button.

                 

                The disable_enable_btns function is used to prevent people from using the buttons during a transition...

                 

                function disable_enable_btns(){

                     for(i=1; i<6; i++){

                          // switch the enabled property to its opposite

                          this["btn"+i].enabled = !this["btn"+i].enabled;

                     }

                }

                 

                So you call that function in the button code, and you also call it in the last frame of each transition so that when a transition is done, the buttons are once again enabled.

                1 person found this helpful
                • 5. Re: Help Newbie With Company Website Idea
                  Meb Moon Level 1

                  Hi again Ned,

                   

                  I want you to know how much I appreciate your help. 

                   

                  First, just let me say, you are completely right, I only need four tweens per logo, since a shape doesn't need to tween into itself   So, I'll need a total of 20 tweens, not 25. 

                   

                  I really did read your posts several times. They are very legible and well written.  However, probably due to my own stupidity, I keep hitting the same wall.  So, let me try to explain one more time where I'm getting confused.  If I'm just being stupid, just ignore this post and I'll keep studying from your former posts and figure it out somehow

                   

                  The way I understand your advice, it seems to imply that each logo will only have 1 frame label each.  If I am wrong about that, then obviously I'm totally misunderstanding you.  In my mind, for each individual logo, the "currentLogo" variable would be any of 5 different frame labels. 

                   

                  So, therefore when you wrote:

                   

                  gotoAndPlay(currentLogo+"ToLogo2");

                   

                  I feel like it could be telling Flash something like:

                   

                  gotoAndPlay logo3ToLogo4+logo4Tologo2

                   

                  and then my brain explodes

                   

                  I'm almost afraid to post this because I'm sure I'm missing something.

                   

                  Thanks again so much.

                   

                  Meb

                  • 6. Re: Help Newbie With Company Website Idea
                    Ned Murphy Adobe Community Professional & MVP

                    currentLogo is assigned the name of the current logo... logo1, logo2, logo3....

                     

                    if you have 20 tweens, you have twenty frame labels... logo1ToLogo2, logo1ToLogo3, logo1ToLogo4....

                     

                    The code I gave you will pretty much plug right in for the button for logo2

                     

                    If your brain needs to explode to understand this, I recommend letting it happen... distracted thought can often lead to understanding... this is not that difficult so you need to relax the brain a bit

                    • 7. Re: Help Newbie With Company Website Idea
                      Meb Moon Level 1

                      Hi again Ned.  I appreciate your patience

                       

                      So, I made a small test version of the site, with just 2 buttons and 2 shape tweens.  It sorta works, but unpredictably.  It seems I need to click each button twice before it will play the tween.  Of course, I had to add stop actions at the end of each tween.  Do you think that is causing the problem?  Here's the code I currently have on frame one of the actions layer:

                       

                      var currentLogo:String = "logo1,logo2";

                       

                      logo1.onRelease = function(){

                           disable_enable_btns();

                           gotoAndPlay(currentLogo+"ToLogo1");

                           currentLogo = "logo1";

                      }

                       

                      logo2.onRelease = function(){

                           disable_enable_btns();

                           gotoAndPlay(currentLogo+"ToLogo2");

                           currentLogo = "logo2";

                      }

                       

                      function disable_enable_btns(){

                           for(i=1; i<6; i++){

                                // switch the enabled property to its opposite

                                this["btn"+i].enabled = !this["btn"+i].enabled;

                      }

                      }

                       

                      Thanks again,

                       

                      Meb

                      • 8. Re: Help Newbie With Company Website Idea
                        Ned Murphy Adobe Community Professional & MVP

                        Work at it.  The only problem I see with the code is you use different names for the buttons than my example did, so your disable_enable function isn't disabling/enabling anything.

                        • 9. Re: Help Newbie With Company Website Idea
                          Meb Moon Level 1

                          Hi again Ned,

                           

                          The strange thing is that when I give the buttons instance names matching your example, everything stops working.  I'll certainly keep working at it.

                           

                          Thanks again,

                           

                          Meb

                          • 10. Re: Help Newbie With Company Website Idea
                            Meb Moon Level 1

                            Hi again Ned (or anyone else lurking around),

                             

                            Okay, so I fixed a few things I had setup wrong and things are working somewhat better now.  The main issue remaining is that when I test the movie, I have to first click on a button (any of them) and then click on a different button in order for the buttons, etc. to start functioning properly.  Any ideas what could be causing that?

                             

                            Oh, and I still haven't been able to get the Disable/Enable function to work.  It is currently commented out.  Every time I put it back in everything stops working. 

                             

                            Here's the code I am currently using:

                             

                            stop();

                             

                            var currentLogo:String = "logo1,logo2,logo3";

                             

                            btn1.onRelease = function(){

                                 //disable_enable_btns();

                                 gotoAndPlay(currentLogo+"ToLogo1");

                                 currentLogo = "logo1";

                            }

                             

                            btn2.onRelease = function(){

                                 //disable_enable_btns();

                                 gotoAndPlay(currentLogo+"ToLogo2");

                                 currentLogo = "logo2";

                            }

                             

                            btn3.onRelease = function(){

                                 //disable_enable_btns();

                                 gotoAndPlay(currentLogo+"ToLogo3");

                                 currentLogo = "logo3";

                            }

                             

                            function disable_enable_btns(){

                                 for(i=1; i<6; i++){

                                      // switch the enabled property to its opposite

                                      this["btn"+i].enabled = !this["btn"+i].enabled;

                            }

                            }

                             

                            Thanks again for your time.

                             

                            Meb

                            • 11. Re: Help Newbie With Company Website Idea
                              Ned Murphy Adobe Community Professional & MVP

                              This line is wrong: var currentLogo:String = "logo1,logo2,logo3";  Assign one, only one.

                               

                              As for the disable_enable function where else do you include calls to it.  I have explained where else it needs to be.

                              1 person found this helpful
                              • 12. Re: Help Newbie With Company Website Idea
                                Meb Moon Level 1

                                Wow Ned, thanks so much!  All of the transitions and buttons are working great now.  I appreciate your help so much. 

                                 

                                As for the disable/enable function...  I'm sure you were rolling your eyes, waiting for me to re-read the sentence in one of your posts telling me that I needed to put that function on the last frame of each transition.   However, after doing that, the buttons stop working after 2 or 3 clicks.  They do work at first though.  But, at this point at least, the ability to click the buttons mid-transition isn't causing any issues.  So, that's alright.

                                 

                                Thanks again for all the help.

                                 

                                Meb

                                • 13. Re: Help Newbie With Company Website Idea
                                  Ned Murphy Adobe Community Professional & MVP

                                  You're welcome Meb