12 Replies Latest reply on Dec 21, 2007 9:54 AM by meglundy

    Action Script 2 help

    meglundy
      Ok so here it is. I have a movie clip with continuous scrolling thumbnail movie clips inside it. Here is what I need to happen:

      Upon rolling over the thumbnails the movie clip stops scrolling, when you click on the thumbnails, another movie clip from the _root timeline plays, when you roll off the movie clip they begin to scroll again.

      I have tried everything to get this darn thing to stop moving, what am I doing wrong?

      here is where the source code lies: http://www.sortismarketing.com/lifeline/flash/index.html
        • 1. Re: Action Script 2 help
          dr_ross Level 1
          Couldn't see any source code there, i'm guessing from your description that the animation scrolling the images is a timeline tween rather than a code driven animation. If thats the case then its probably just a slight error in the path when you're trying to call your ScrollingMovie.stop().

          If you post up the code for stopping and starting here or the link to the fla then it should be straight forward
          • 2. Re: Action Script 2 help
            meglundy Level 1
            ooh crud sorry, thats what it looks like now.

            this is code file:
            http://www.sortismarketing.com/lifeline/flash/index_12_17_07.fla
            • 3. Re: Action Script 2 help
              meglundy Level 1
              nope, its a code driven scrolling function using onClipEvent and _y properties.
              • 4. Re: Action Script 2 help
                dr_ross Level 1
                All i've done is take all the code off each image and put it all together on the root, made two functions, one stop one start, and set a custom move function to the onEnterFrame handler of each image to start, and delete it to stop. And of course give your main movieclip an instance name to be able to reference each image in a loop.

                You could add your onRollOver handler to each in the same manner without having to bury it inside movieclips again.

                http://www.bestsharing.com/files/6v36qx382875/index_12_17_07.fla.html

                If you need any more help with it give me a shout,
                • 5. Re: Action Script 2 help
                  meglundy Level 1
                  Thats a great scroller thankyou! Can you tell me how I would right the code to stop or pause it from scrolling and also I want to play another movie clip on release.

                  These attempts don't work, what am I missing:

                  feat1.onRollOver = function(){
                  featProd.stop();
                  }

                  feat1.onRollOver = function(){
                  stopScrolling = true;
                  }

                  feat1.onRollover = function(){
                  stop()();
                  }

                  and these functions or statements would go under the _root as well correct? (where you put the other action script??)
                  • 6. Re: Action Script 2 help
                    meglundy Level 1
                    and how do I get the output thing to stop coming up?
                    • 7. Action Script 2 help
                      dr_ross Level 1
                      i've updated it to include the functionality you've asked for and added functions for if the user presss or releases the thumb, you could put a if/else or case statement in them to decide what to do if the user presses them.

                      Anything that appears in the output panel is from trace() commands, just comment them out to stop it

                      http://www.bestsharing.com/files/HPmUV382993/index_12_17_07.fla.html

                      Hope that helps, DrRoss

                      Edit:- you can change the numbers in the thumbMover function to get the functionality you need, and of course mask as per normal
                      • 8. Re: Action Script 2 help
                        meglundy Level 1
                        Thank you so much for all of your help. I just have one last question.

                        This code is so far above my ahead, where do I put the thumb's onRelease function?? And will it look something like this

                        feat1.onRelease = function(){
                        feat1_mc.play(){
                        }
                        }

                        since I don't quite understand your code, i'm at a loss at to where I should be putting these onRelease functions and how to write them.

                        Meghan
                        • 9. Re: Action Script 2 help
                          meglundy Level 1
                          OH MY GOD I FIGURED IT OUT !!!

                          ALL BY MYSELF!

                          :o)
                          • 10. Re: Action Script 2 help
                            meglundy Level 1
                            :o(

                            I lied! for some reason now you release on any of the thumbs it plays the same thing :o(

                            function thumbReleased() {
                            //this refers to the thumb released
                            if(_root.main.featProd.feat1.onRelease){
                            _root.main.feat1_mc.play();
                            }else if(_root.main.featProd.feat2.onRelease){
                            _root.main.feat2_mc.play();
                            }else if(_root.main.featProd.feat3.onRelease){
                            _root.main.feat3_mc.play();
                            }else if(_root.main.featProd.feat4.onRelease){
                            _root.main.feat4_mc.play();
                            }
                            }

                            what am I doing wrong??
                            • 11. Re: Action Script 2 help
                              dr_ross Level 1
                              i think you need something like this, just replace the trace statement sith what ever you need,

                              function thumbReleased()
                              {
                              //this refers to the thumb pressed
                              trace(this);

                              if(this == _root.main.featProd.feat1)
                              {
                              trace("do action for feat 1");
                              }else if(this == _root.main.featProd.feat2)
                              {
                              trace("do action for feat 2");
                              }else if(this == _root.main.featProd.feat3)
                              {
                              trace("do action for feat 3");
                              }else if(this == _root.main.featProd.feat4)
                              {
                              trace("do action for feat 4");
                              }
                              }

                              and then when you feel comfortable with that try using a switch case statement instead of the if/else.
                              • 12. Re: Action Script 2 help
                                meglundy Level 1
                                ok so here is what I have so far:

                                import mx.utils.Delegate;
                                function thumbMover() {
                                this._y = this._y+1;
                                if (this._y>=418) {
                                this._y = -50;
                                }
                                }
                                function startScrolling() {
                                for (var i = 1; i<5; i++) {
                                var feat = this.main.featProd["feat"+i];
                                feat.onEnterFrame = thumbMover;
                                feat.onRollOver = Delegate.create(this, stopScrolling);
                                feat.onRollOut = Delegate.create(this, startScrolling);
                                feat.onPress = thumbPressed;
                                feat.onRelease = feat.onReleaseOutside=thumbReleased;
                                }
                                }
                                function thumbPressed() {
                                //this refers to the thumb pressed
                                if (this == _root.main.featProd.feat1) {
                                _root.main.feat1_mc.gotoAndPlay(1);
                                } else if (this == _root.main.featProd.feat2) {
                                trace("do action for feat 2");
                                } else if (this == _root.main.featProd.feat3) {
                                trace("do action for feat 3");
                                } else if (this == _root.main.featProd.feat4) {
                                trace("do action for feat 4");
                                }
                                }
                                function thumbReleased() {
                                //this refers to the thumb released
                                }
                                function stopScrolling() {
                                for (var i = 1; i<5; i++) {
                                delete this.main.featProd["feat"+i].onEnterFrame;
                                }
                                }
                                this.startScrolling();


                                now here is the problem. When you click on feat1, it plays the movie, but then when you click it again instead of playing the movie again, the movie disappears, and then if you click a third time it plays the movie again. It needs to play the movie each time you click on feat1

                                and the same for all the other thumbs: feat2, feat3, feat4.

                                basically if you click feat1, play feat1_mc, stop all the other feat_mc's from playing

                                if you click feat2, play feat2_mc, stop all the other feat_mc's from playing....