7 Replies Latest reply on Mar 15, 2011 10:59 AM by Ned Murphy

    How to play a movie clip with a tween animation

    jaswerl

      I created a movie clip symbol with a tween animation and created an instance of it on the main stage. The animation is in the movie clip timeline, not on the main timeline. I cannot get the mc to play using mc.play() or mc.gotoAndPlay.  What am I missing??

        • 1. Re: How to play a movie clip with a tween animation
          Ned Murphy Adobe Community Professional & MVP

          Did you assign the instance the instance name "mc"?  Is the animation created along the timeline of the mc (you say it is "in" that timeline, but is it yet another movieclip in that timeline)?

          • 2. Re: How to play a movie clip with a tween animation
            jaswerl Level 1

            Hi Ned, thanks for the response;

             

            1.Yes I named the instance.

            2.I  don't beleive so. I started from the library creating a new symbol, added the graphics, added the key frames, then created the tween. Then I dragged the symbol onto the main stage and named the instance. So I don't think there is a movie clip inside an mc.

             

            Here is the main timline:001.png

             

            Here is the mc timeline:002.png

             

            Here is what I'm trying to do:

             

            stop();

            blk1._visible = false;

            blk2._visible = false;

            blk3._visible = false;

            ppk1._visible = false;

            ppk2._visible = false;

            ppk3._visible = false;

             

            storeCartons = new Array();

            storeCartons = [blk1, blk2, blk3, ppk1, ppk2, ppk3];

             

            startButton.onRelease = function() {

                myNumber = Math.floor(Math.random()*storeCartons.length);

                trace("myNumber "+myNumber);

                activeCarton = storeCartons[myNumber];

                activeCarton._visible = true;

                      activeCarton.play();

             

            };

             

             

            • 3. Re: How to play a movie clip with a tween animation
              Ned Murphy Adobe Community Professional & MVP

              There's nothing wrong with the code as shown, so as long as the instance names have been properly assigned, the code should work.  But for the animations themselves, you do not show anything that stops the animations, in which case they would be play continuously... no need to tell them to play().

              • 4. Re: How to play a movie clip with a tween animation
                jaswerl Level 1

                Got it. Thanks. I added the stop(); to the last fram of  each mc and it worked.

                 

                Now why does the drag and drop not work?

                 

                stop();
                blk1._visible=false;
                blk2._visible=false;
                blk3._visible=false;
                ppk1._visible=false;
                ppk2._visible=false;
                ppk3._visible=false;

                storeCartons = new Array(blk1, blk2, blk3, ppk1, ppk2, ppk3);
                //storeCartons = [blk1, blk2, blk3, ppk1, ppk2, ppk3];

                startButton.onRelease = function() {

                    myNumber = Math.floor(Math.random()*storeCartons.length);

                    trace("myNumber "+myNumber);

                    activeCarton = storeCartons[myNumber];

                    activeCarton._visible = true;

                    activeCarton.play();

                }

                activeCarton.onPress = function(){
                startDrag(this,true)
                }

                activeCarton.onRelease = function(){
                this.stopDrag();
                checkTarget(this);
                }

                activeCarton.onReleaseOutside = function(){
                this.stopDrag();
                checkTarget(this);
                }

                function checkTarget(drag){

                if (drag.hitTest(blkStaging)) {
                trace(drag+" has been dropped on greyCircle");
                } else {
                trace("you missed the target");
                }

                • 5. Re: How to play a movie clip with a tween animation
                  Ned Murphy Adobe Community Professional & MVP

                  Try moving the activeCarton functions inside the startButton function.  The activeCarton object is not defined outside of that function... speaking of which, you should always declare variables... change...

                   

                  activeCarton = storeCartons[myNumber];

                   

                  to

                   

                  var activeCarton = storeCartons[myNumber];

                  • 6. Re: How to play a movie clip with a tween animation
                    jaswerl Level 1

                    That worked. Thanks a bunch.