8 Replies Latest reply on May 13, 2007 11:23 PM by Rick Gerard

    movie control question...

    Rick Gerard Adobe Community Professional & MVP
      Ok, I'm pretty good with After Effects expressions, but action script is still a bit of a mystery to me.

      Here's what I want to do. I've got these 7 movies that activate when you roll over their hit spot. Each of the movies has an open that's about 10 frames, then a looping section created by a go to and play 11 script, and then a close that is about 10 frames long. The open is a simple scale up and fade up, the close is a simple fade out and scale down.

      I've got the script working now so that when you roll over and keep over the hit spot the movie plays through the open and then loops until you move off the hit spot. If you happen to move off at the end of the loop then you get a smooth out, but if you don't there is a jump in the action as the movie skips the frames remaining to the end of the loop and just plays the end section.

      I've searched long and hard and can't find any technique that would make sure that the movie opens plays completely through the loop section and then without skipping any frames plays the end frame even if you rolled over the hit area and then back out on say frame 3 of the movie. IOW, the movie must play without interruption from beginning to end every time, but if you hover over the hit area the loop will continue until you move out.

      Adding to the dilemma is that these movies are stacked basically on top of each other so that when you roll over a new hit area while another movie is playing the new movie may or may not be on top of the first movie. I was getting a lot of funky flashing layers so I came up with a move to front (can't remember the exact code right now) script that brings the movie associated with the current hit spot to the front. All is pretty good, but it would be better if there were some kind of script that I could come up with that says if any of the other movies are still playing wait until they complete before planing the currently selected movie. This would prevent any flashing of the layers as one movie is moved to the top of the stack. It may even eliminate the need for the bring to the front section of my script.

      I hope the description is clear enough. Hopefully I'll learn enough about this Action script stuff to be of some help to others in the future.

      BTW, I prefer an action script 3 solution, but I've built these pages with both 2 and 3 so either will do just fine.

        • 1. Re: movie control question...
          To this I do not give code, it is rather a comment of Your design aproach. To me it's lika a trap if You try to keep tha visitor in a movie after he/she have been leaving your button. If You start a movie when the visitor enter a button then You should end all the activities asociated with the button and set the visitor free to do other things. If the visitor start an activity with (for instance) click on a button it is a another matter because then the visitor have made a deliberate choice and he/she can choose to do another activities later.
          Do not take the visitor's right to deside form him. This will even make Your work easier: Stop and Go - all the time.
          • 2. Re: movie control question...
            rayden_chan Level 1
            Ok, first of all, i have to tell that the way you explain stuff are quite complicated.

            I know the answer to ur question but it's going to use some code.

            Try this, what u gonna do is:
            on the first frame of the movie, u write a code: var isHit:Bool = false;

            and then, in your button, you write:
            if( ! _root.isHit )
            _root.isHit = true;

            and finally, on ur movieclip that contain animation: someClip_mc
            u place this code at the end of the frame:
            _root.isHit = false;

            good luck!
            • 3. Re: movie control question...
              RaGlitter Level 1
              Rayden was pretty close to the answer. What i think you want is this.

              If, when the animation on your button gets to the end, the cursor is no longer over that button, play the out animation, otherwise continue the loop.

              This is achived by setting a variable that keeps track of if the cursor is over the button:

              In your rollover script (in addition to the current code):

              myButtonMCName.overButton = true;

              in your loop code:

              if(overButton == true){

              in your rollOut function (instead of your current gotoAndPlay):

              myButtonMCName.overButton = false;

              Good luck
              • 4. movie control question...
                Rick Gerard Adobe Community Professional & MVP

                Thanks for this reply but the design is for some roll over items to be clicked on and the movies take less than a half second to open and close, and the looping is just to keep things interesting until clicked on to navigate to another spot on the site. The site is quite responsive, I just don't want any funky overlapping menus and I want things to look smooth.
                • 5. movie control question...
                  Rick Gerard Adobe Community Professional & MVP
                  And thanks Raden and Jon for the suggestions. These are something like I was trying to build. I'll let you know how they work.

                  Thanks again.
                  • 6. movie control question...
                    Rick Gerard Adobe Community Professional & MVP
                    I can't seem to get this to work. Maybe I'm not describing the problem clearly enough.

                    All I want is for a movie clip which starts to play when you roll over the hit area to continue to the end without interruption if you accidentally roll out before it's over. I also want to prevent a restart if you roll back in before the movie completes. The final thing on my wish list is that if the movie has not completed then I don't want any of the other hot spots for the other movies on the page to work until this movie has closed.

                    This is just a simple 7 item menu with animated buttons. The way it works now, if you roll out early there's a jump to the end, if you roll back in quickly there's a jump back to the start. The whole thing looks very . . . jumpy and it should look very smooth and relaxed.

                    If you need some files let me know. Here's a short sample of the existing code. There are 25 frames in each movie.
                    • 7. Re: movie control question...
                      RaGlitter Level 1
                      function over () {
                      this.overThis = true;

                      function out () {
                      this.overThis = false;

                      Script for the movie:

                      Frame 2 :
                      if(overThis == false){

                      Frame 15:
                      if(overThis == true){

                      Any clearer?

                      • 8. movie control question...
                        Rick Gerard Adobe Community Professional & MVP
                        This helps. Getting there as a matter of fact. Thank you.

                        I seem to still need a stop in frame 1 of the movie and I need to have the function read as follows to make things work:

                        function over () {
                        this.overThis = true;
                        this.gotoAndPlay ("start");

                        I thought I could remove the gotoAndPlay statement and the Stop() at the head of the movie, but I couldn't .

                        The only problems remaining are that if you roll back over the button before the movie ends you jump to the loop section.
                        I'd also like to be able to switch layers so the last button rolled over would always be on the top.

                        Here's a link to my test project. I'm using buttons instead of rolling over the movie. You'll also find a link on the page to the .fla file.

                        Thanks again for the help. I hope to get this completed tomorrow.