13 Replies Latest reply on Oct 6, 2007 6:20 AM by clbeech

    go to and play

    serg2049 Level 1
      I'M REPHRASING MY EXPLANATION, PLEASE LOOK AT THIS FIRST:

      TO PUT IT SIMPLE: I have mc1,mc2 and mc3 (movie clips)
      each has a script, let's say function1,function3 and function3.

      How can I tell the animation with actionscript this:

      Execute function1 for mc1, after this is done execute function2 for mc2 and after it is finished executing function2 execute funtion3 for mc3

      OK, THIS IS THE EXPLANATION I HAD BEFORE: I've seen some examples where with actionscript you can direct the animation to go and play a movie that's in a certain layer, then from there go and play anothe rmovie in anothe rspecific layer without playing others, something like that.

      Can anyone direct me to a tutorial or flash movie where I can study how to do this?
        • 1. Re: go to and play
          kglad Adobe Community Professional & MVP
          you can't do that. layers don't exist outside the authoring environment.

          so, if you have two movieclips on the same frame, whether they are in different layers or not, and you direct the timeline to that frame, both will play - unless you there's some additional code to stop one (or both of them). and adding that additional code can be done.
          • 2. Re: go to and play
            serg2049 Level 1
            Well, then how can I do this:

            indicate the first frame to play the movie clip in it which functions by actionscript, for example:

            on frame 1 I have:
            cow_mc.onEnterFrame=function(){
            this._x-=(this._x-grass_mc._x)*.1
            }

            So with actionscript I want to have this script to execute and when it finishes I want the animation to go to the second frame and execute this script:

            mouth_mc.onEnterFrame=function(){
            this._x-=(this._x-grass_mc._x)*.1
            }

            And from there go frame by frame executing each script. So it would need to stop the timeframe while it finishes playing each script.

            Anyone can tell me please, or direct me to a tutorial, something like that?
            • 3. Re: go to and play
              clbeech Level 3
              ok there are several ways to do this. you could use conditions, in which you should also stop the executing onEnterFrame. or you could use the Tween class. I would opt for the Tween class since you're doing more of a 'straight' animated sequence (no user interaction). You need to determine how far the cow_mc is moving then replace the onEnterFrame event with this:

              stop();
              import mx.transitions.Tween;
              import mx.transitions.easing.None;

              var cow:Tween = new Tween(cow_mc, '_x', None.easeNone, (cow_mc._x starting point), (cow_mc._x ending point), (how many frames), false);

              ... replace the items in ( ) with the values you determine, then use the call ...

              cow.onMotionFinished = function() {
              gotoAndStop(2);
              }

              ... to move the playhead and start the next section, in which you would do something similar with the 'mouth_mc'. OR without moving the playhead to frame 2 your could just call another Tween that moves the mouth in sequence as in ...

              cow.onMotionFinished = function() {
              var mouth:Tween = new Tween(mouth_mc, '_x', ... );
              }

              ... ammend the remaining values.
              • 4. Re: go to and play
                serg2049 Level 1
                Ok, I think the tween solution wouldn't work cause the movie cow_mc doesn't have any frames in it, it executes just by math.

                So what I need I think is doing it with conditions. Could anyone explain how to do it using conditions? or direct me to a tutoriaL

                thanks :)
                • 5. Re: go to and play
                  clbeech Level 3
                  well, no actually, it would replace the onEnterFrame function you have and simply move the cow_mc to the left, which is what you code above is doing, the cow_mc doesn't need to have frames in order for this to work, and actually is the method of choice in many movement situations.

                  But that's fine, how do you know when the first animation is complete? do you have a function that is monitoring the progress or something? In the code you have above, there is no 'end' it will continue to move to the left. you need to have a condition in the event that tells it to stop at a given point, then you can terminate the loop and move to the next frames actions like so:
                  • 6. Re: go to and play
                    serg2049 Level 1
                    clbeech thanks I'll try it :)
                    • 7. Re: go to and play
                      serg2049 Level 1
                      It didn't work :( any other suggestions?
                      • 8. Re: go to and play
                        clbeech Level 3
                        serg, can you post your file, so I can see more of what you need here. This is relatively straight forward, so it should have worked, it must have to do with the way you've got things structured. I can help you figure this out, but I need more info.

                        Just zip the fla, upload it to your server and post a link to the file here using the 'Reply' link in the top of each post.
                        • 9. Re: go to and play
                          serg2049 Level 1
                          will do, but I gotta take off, if you were so kind to check tomorrow I'll really appreciate. Thanks.
                          • 10. Re: go to and play
                            serg2049 Level 1
                            clbeech, I modified your code and merged it with another code I had and it worked, look.

                            stop();

                            onEnterFrame=function() {
                            cow_mc._x-=(cow_mc._x - grass_mc._x)*.1;
                            if(cow_mc._x>380)
                            gotoAndStop(2);
                            }
                            • 11. Re: go to and play
                              clbeech Level 3
                              very good, however you should also terminate the interval once the condition has been satisfied, add:

                              if(cow_mc._x>380) {
                              delete onEnterFrame;
                              gotoAndStop(2);
                              }
                              • 12. Re: go to and play
                                serg2049 Level 1
                                Thanks.

                                I also did another derivation, as to have the movie stop for a while after it moves.

                                stop();
                                secs = 5;
                                function me() {
                                gotoAndStop('mouth');
                                clearInterval(pauseInt);
                                }
                                onEnterFrame=function() {
                                cow_mc._x-=(cow_mc._x - grass_mc._x)*.3;
                                if(cow_mc._x>grass_mc._x)
                                delete me;
                                pauseInt = setInterval(me, secs * 1000);
                                }

                                Don't know if that code could cause any problems, I just merged it with a pause code...
                                • 13. Re: go to and play
                                  clbeech Level 3
                                  OK serg, looks fine, but (and it may be a typo) you should be deleting the onEnterFrame event, not the function 'me', otherwise look s fine.