7 Replies Latest reply on Mar 8, 2011 12:44 PM by Ned Murphy

    Photo Gallery AS 2.0 Help

    2acremeadow Level 1

      Hi,

      I am very new to Flash and need some assistance.  I am using CS4 and ActionScript 2.0.  I am trying to create a photo gallery.  I have created 4 different movie clip buttons that reside on the content layer.  Each button consists of one image.  When the movie clip button is pressed, I want the full size image to appear on the stage next to the buttons.  You can see the buttons in the image below.  I am trying to create an empty movie clip holder that would reside on the main timeline while the buttons reside on the content layer.  Can someone help me with the code I need to get the images to load into the empty movie clip and then unload when the next button is selected?  I can't seem to get the buttons to "talk" to the empty movie clip holder.  I did manage to create code for an empty movie clip holder within each button, but then I end up with all four images on top of each other.   Thanks in advance to anyone willing to share their code knowledge.

      PSPage.jpg

        • 1. Re: Photo Gallery AS 2.0 Help
          Ned Murphy Adobe Community Professional & MVP

          What code are you currently using?  You could manually place an empty movieclip on the stage and use that and the loadMovie command to chage the content within it.

          • 2. Re: Photo Gallery AS 2.0 Help
            2acremeadow Level 1

            Hi,

             

            I have placed a movie clip on the timeline.  I named the mc symbol mcHolder in the properties box.  I made sure the registration point was in the top corner.  This is the code I have for one of the photo buttons in the actions panel.  My question is still how do I make the photo show up in the box and leave when the next button is clicked?  The jpg files are in the same folder as the FLA and swf.  Thanks for your help - You can tell I am new at this.

             

            on(rollOver) {
            gotoAndStop("over");
            _level0.spectrumCursor.gotoAndStop("hover");
            }
            on(rollOut) {
            gotoAndStop("up");
            _level0.spectrumCursor.gotoAndStop("normal");
            }
            on(press) {
              loadMovie("cabin.jpg",mcHolder);
            _level0.spectrumCursor.gotoAndStop("click");
            }
            on (release) {
            gotoAndStop("up");
            _level0.spectrumCursor.gotoAndStop("hover");
            }
            on(releaseOutside){
            gotoAndStop("up");
            _level0.spectrumCursor.gotoAndStop("hover");
            }

            • 3. Re: Photo Gallery AS 2.0 Help
              Ned Murphy Adobe Community Professional & MVP

              If you are just starting out, then you should consider forgetting AS2 and move up to AS3.  That said...

               

              Since you are just learning AS2, there is no time better than the present to drop bad coding practices, namely, placing code on objects.  Give your button_mc's instance names, just like you did with the mcHolder, and use timeline code for them.

               

              cabinBtn.onRollOver = function() {
                  cabinBtn.gotoAndStop("over");
                  spectrumCursor.gotoAndStop("hover");
              }

               
              cabinBtn.onRollOut = function() {
                  cabinBtn.gotoAndStop("up");
                  spectrumCursor.gotoAndStop("normal");
              }

               

              // got rid of loading for on(press)... it defies ReleaseOutside intentions

               

              cabinBtn.onPress = function() {

                  spectrumCursor.gotoAndStop("click");
              }

               

              cabinBtn.onRelease = function() {

                  mcHolder.loadMovie("cabin.jpg");

                  cabinBtn.gotoAndStop("up");
                  spectrumCursor.gotoAndStop("hover");
              }


              cabinBtn.onReleaseOutside = function(){
                  cabinBtn.gotoAndStop("up");
                  spectrumCursor.gotoAndStop("hover");
              }

               

              As long as you have each button using the same mcHolder object for loading the images into, the code as you have it will take care of replacing the one previously loaded.

               

               

               

               

               

               

              • 4. Re: Photo Gallery AS 2.0 Help
                2acremeadow Level 1

                Hi Ned,

                While I am trying that out I wanted to ask another question.  By the way, I am enrolled in a course for Flash Web Design.  The instructor is requiring CS4 and AS 2.0.  He will help us with design issues but not with coding.  When this class ends (if I can get my site to work) I will take a class on AS 3 and HTML.

                 

                I do have my movie clip buttons named.  It did not show in the code I provided because the code is inside the action script of each button.  Isn't the name redundant?  Are you saying that all that code should go on the actions layer for the timeline instead of the actions panel for each button?  Thanks again, I really appreciate your assistance.  It is because of people like you that beginners like me keep wanting to learn.  I hope you realize that.

                • 5. Re: Photo Gallery AS 2.0 Help
                  Ned Murphy Adobe Community Professional & MVP

                  Yes, keeping your code on the timeline instead of attaching it to object using on(anything) is the better way to go.  Not only does it provide a more consistent approach to coding, it helps keep your actionscript readily findable/visible, and it prepares for your future plans.  When you get to AS3 you don't have a choice because you are not allowed to place code on objects at all.

                   

                  If your teacher is teaching the on() approach, he could use some education himself, but that's often a disconnect between the real world and academia.  Whatever the case may be, don't challenge him over it.  If he objects to your approach, succumb to his wishes to get the grade... knowing that you know better.

                  1 person found this helpful
                  • 6. Re: Photo Gallery AS 2.0 Help
                    2acremeadow Level 1

                    I can't tell you how much help this has been.  Yes, I often notice quite a difference between what we are being told to do and what I see in the books and forums.  The photogallery is working perfectly.  Just one of the photos is a different size than the others.  How can I code it to move the photo to the center of the holder?  Thanks again.

                    • 7. Re: Photo Gallery AS 2.0 Help
                      Ned Murphy Adobe Community Professional & MVP

                      You would have to move the holder... the holder is the object you are controlling... whatever you load into it assumes the properties of the holder, including its name.  It will be cleaner for you overall if you just make the other image the same size.

                       

                      If you wanted to relocate thing based on the size of what's loaded, you need a different loading vehicle because you have to wait until the object is loaded before you can determine its size.  In order to know when the loading is complete requires using the MovieClipLoader class instead of the loadMovie method, because it supports having listeners for load completion.

                      1 person found this helpful