5 Replies Latest reply: Jul 29, 2010 3:18 PM by newToAS3 RSS

    Movie clips

    Smitch1581 MeganK

      Hi all, hopefully this is a simple question!

       

      I exported a XFL from InDesign to work in Flash and each page is a movie clip on a separate frame, i have animated every movie clip and all is well, i have added a stop(); on an AS layer on the first frame so that the movie clip on the first frame plays without jumping to the 2nd keyframe, however, what i would really like is when the first movie clip finishes on frame 1, the movie clip on the 2nd frame plays automatically and so on up to frame 5.

       

      I thought i could add a instanceName.gotoAndStop(2); or instanceName.gotoAndPlay(2); on the timeline but this stops frame 2 with in the movieclip but it really needs to go to the main timeline instead, if i try and add the script withing the movieclip, errors pop-up but i don't think i should be doing this anyway as i have read i should do all my coding on one and only one keyframe!

       

      Any help would be greatly appreciated

       

      thank you in advance:-)

        • 1. Re: Movie clips
          newToAS3 Community Member

          I don't know/understand how you're animating your movieClips you got from InDesign.

           

          If you're using timeline animation, one thing you could do is write some code in the last frame (end of the animation) of each one of your movieClips.

          Something like this:

           

          parent.gotoAndStop(2); //tells the current movieClip parent (in your case
          //the timeline, to gotoAndStop(2).
          

           

          There are other things you could do but this is the easiest one that I can think of for now.

          Other solutions would depend on your file structure. You could, for example, dispatch a new event from the end of each one of your movieClips and listen for this event on your main timeline and then gotoAndStop(someFrame);

           

          If all your animations are very similar in time, you could try a timer (I hate this idea hehe).

           

          Well, let me know if the first one works.

          • 2. Re: Movie clips
            Smitch1581 MeganK

            Hi newToAS3,

             

            Thankyou very much for your reply, sorry if i'm being dumb but i am really NewToAS3!

             

            I tried copying the text into the last key frame of the movie clip and i got the following  error message

             

            Call to display undefined method gotoAndStop through a reference with static type flash.display:DisplayObjectContainer. I then google that and there was a similar thread. Got the code as follows:

             

            stop();

            var p:MovieClip = parent as MovieClip;

            p.gotoAndStop(2);

             

            That seemed to work but have no real idea how! The thread said something about casting

             

            "You need to cast parent to a MovieClip, like this:
            var p:MovieClip = parent as MovieClip;
            because parent is typed as DisplayObjectContainer"

             

            I kind of get it but dont truly understand casting and the "parent as MovieClip;" command :-)

             

            Thankyou for your help tho, you have helped me get the answer

             

            Cheers :-)

            • 3. Re: Movie clips
              newToAS3 Community Member

              Yep.

               

              Flash "think" you can't gotoAndStop on your parent's movieClip. You would probably get almost the same error if you try to use gotoAndStop in a textField or a Sprite for example. Flash will tell you: are you going nuts?! this is not a movieClip that you can gotoAndStop, this is a text field dude!

               

              Indeed, but in your case, we know that your parent has frames and that you can "walk" within the frames of your "Stage" object using gotoAndStop. Unfortunately, flash seems not to be smart enough to know that (at least I think). So you "cast" your paren't object as a MovieClip that flash knows that you can gotoAndStop inside movieClips.

               

              You're basically saying: Hey, listen Flash, my dear, I know that the parent of this object has a timeline full of frames and that I can "gotoAndStop". Now, consider it a MovieClip and stop(); bothering me... Thanks!

               

              btw, I haven't tried that but instead of using a new var to "hold" your movieClip's parent, you could simply use

               

              MovieClip(parent).gotoAndStop(2);
              

               

              This should work too, but I'm not really sure about that.

               

              Anyway, I'm happy you got your problem solved!

              • 4. Re: Movie clips
                Smitch1581 MeganK

                I see, thats great and your example worked too and i now understand how that works! Your down to earth analogy was spot on! The jargon i've read in books sometimes baffles me!

                 

                Thank you very much for your help, its greatly appreciated :-)

                • 5. Re: Movie clips
                  newToAS3 Community Member

                  =)