15 Replies Latest reply on Mar 25, 2009 12:34 PM by Govadica

    actionscript 2 nightmare

    remouski
      Hi, I have a client who would like to have an animation of her items with underneath a small thumbnail version of her items scrolling. please check it at http://www.rayank.co.uk/
      What I need to do at this stage is when a thumbnail image is selected it calls the same image in the animated gallery. Can anyone help?
        • 1. Re: actionscript 2 nightmare
          kglad Adobe Community Professional & MVP
          what's the problem?
          • 2. Re: actionscript 2 nightmare
            remouski Level 1
            Well when u click on the thumbnail image it doesn't take you to the main image in the gallery.
            • 3. Re: actionscript 2 nightmare
              kglad Adobe Community Professional & MVP
              and what is the code that is failing?
              • 4. Re: actionscript 2 nightmare
                remouski Level 1
                I am not sure of which code to use. I created the animation in After Effects as it wasn't smooth enough in flash and I've imported it into flash. I don't know how to write the code so when a certain image in the thumbnail is clickded the main animation jumps to that specific image. I know there has to be a gotoAndPlay somewhere but I am not sure how to fit it in this

                for (i=1; i<=imagesNumber; i++) {
                container.attachMovie("thumb"+i,"thumb"+i+"_mc",i);
                myThumb_mc = container["thumb"+i+"_mc"];
                myThumb_mc._x = (i-1)*myThumb_mc._width;
                myThumb_mc._y = (Stage.height*0.9-myThumb_mc._height);
                myThumb_mc._alpha = 50;
                myThumb_mc.onRollOver = function() {
                this._alpha = 100;
                };
                myThumb_mc.onRollOut = function() {
                this._alpha = 50;
                };
                myThumb_mc.onRelease = function() {
                this._alpha=50;
                for (i=1; i<=imagesNumber; i++) {
                var myClip = container["thumb"+i+"_mc"];
                myClip.enabled = false;
                }
                scrolling = false;

                Needless to say that I got this piece of code from the internet.

                In short when a user selects an thumbnail from the scrolling gallery it calls up the same image in the main/bigger animated gallery. I am not sure how to scrip this.
                • 5. Re: actionscript 2 nightmare
                  kglad Adobe Community Professional & MVP
                  there's no one answer that will work for you. you must code according to the logic in you application.

                  so, if each thumbnail has an associated main timeline keyframe where the large image is ready for display, you would use something like:

                  myThumb_mc.onRelease = function() {
                  _root.gotoAndPlay(this.gotoFrame)

                  but, in addition, to satisfying all the "ifs" in the paragraph above, you also need to define each thumb's associated keyframe, gotoFrame.
                  • 6. Re: actionscript 2 nightmare
                    remouski Level 1
                    yes but how do I define my thumbnails (I have 14 of them), because myThumb_mc is not defined to an individual thumbnail. Do I rename each one and say something like if thumbnail1 is selected then gotoAndplay frame 5? It feels like there must be more of a straight forward way.
                    • 7. Re: actionscript 2 nightmare
                      kglad Adobe Community Professional & MVP
                      your thumbnails are named using the code you showed.

                      are you using that code to create your thumbnails and place them on-stage?
                      • 8. Re: actionscript 2 nightmare
                        remouski Level 1
                        The thumbnails are called and placed on stage using script (as far as I can tell, as I am fairly new to actionscript). So basically i in the code represents the thumbnails' number, so how do I call the thumbnails in my gotoAndPlay the appropriate frame number in my main animation?
                        • 9. Re: actionscript 2 nightmare
                          kglad Adobe Community Professional & MVP
                          what's the frame label (or frame number) that you want to use to display the large image when your ith thumb ( container["thumb"+i+"_mc"] ) is released?
                          • 10. Re: actionscript 2 nightmare
                            remouski Level 1
                            that's just it "i" is always different depending on where the mouse is, it represents the thumbnail number. so when the user selects thumbnail 6 (i=6?) then gotoandplay whatever frame label. I am not sure how to write the code without having to redefine each thumbnail.
                            • 11. Re: actionscript 2 nightmare
                              kglad Adobe Community Professional & MVP
                              well, thumbnail i must correspond to some frame label. even if those labels aren't chosen logically with the idea of using them in a for-loop, you can always use an array:

                              framelabelA=["frame label for thumb1","2nd frame label thumb","3rd label",etc];

                              for (i=1; i<=imagesNumber; i++) {
                              container.attachMovie("thumb"+i,"thumb"+i+"_mc",i);
                              myThumb_mc = container["thumb"+i+"_mc"];
                              myThumb_mc.ivar = i;
                              myThumb_mc._x = (i-1)*myThumb_mc._width;
                              myThumb_mc._y = (Stage.height*0.9-myThumb_mc._height);
                              myThumb_mc._alpha = 50;
                              myThumb_mc.onRollOver = function() {
                              this._alpha = 100;
                              };
                              myThumb_mc.onRollOut = function() {
                              this._alpha = 50;
                              };
                              myThumb_mc.onRelease = function() {
                              _root.gotoAndPlay(framelabelA[this.ivar-1]);
                              this._alpha=50;
                              for (i=1; i<=imagesNumber; i++) {
                              var myClip = container["thumb"+i+"_mc"];
                              myClip.enabled = false;
                              }
                              scrolling = false;

                              • 12. Re: actionscript 2 nightmare
                                remouski Level 1
                                thanks kglad will give it a go.
                                • 13. Re: actionscript 2 nightmare
                                  kglad Adobe Community Professional & MVP
                                  you're welcome.
                                  • 14. Re: actionscript 2 nightmare
                                    remouski Level 1
                                    Just a line to tell you it works, but I was wondering if you could explain this line:
                                    myThumb_mc.ivar = i

                                    Cheers
                                    • 15. Re: actionscript 2 nightmare
                                      Govadica Level 1
                                      Thanks man.

                                      Garmin 1390t