4 Replies Latest reply on Jul 5, 2010 10:51 PM by dn0myar06

    mc calling


      is it possible to play mc in a specific time frame from the outside??


      i'm actually making a card matching game and i'm having problem flipping the 1st card back if the cards don't match...

      i made 2 animation in 1 mc...the first one is to see the behind of the card...and the other one is to turn it back if wrong...


      so is there a way that i could play the mc of the first card to frame 30 when clicking the 2nd card and they don't match??

        • 1. Re: mc calling
          kglad Adobe Community Professional & MVP

          yes, you can use gotoAndPlay() to play a sequence of frames.  if you want to stop at a certain point or play a sequence of frames backwards use an onEnterFrame loop.

          • 2. Re: mc calling
            dn0myar06 Level 1

            but it only plays the mc itself...


            i actually need to play the other mc....is this possible??

            _parent.1buttonMovie1.gotoAndPlay(30); ??


            i need to play the mc of the first card that has been clicked...


            hope you could help.. thanks in advance

            • 3. Re: mc calling

              Ok, I'm sure there are many ways to accomplish this, and I'm sure that many would scoff at my crappy scripting, but this may work for you.


              First I'm assuming that you are going to have quite a few cards that get flipped and each one is a MC that has 60(ish) frames.  The first thirty to flip it one way, and another thirty to flip it back.  Since any card can be the first one flipped, you will have to use a variable to reference that card when the second one is flipped. To avoid all the _parent crap I just use a _global variable. So here's what I'm thinking:


              //set the event handler on the card (I will use card1_mc)


              card1_mc.onRelease = function(){

                   //flip the selected card over





              //I presume you have a stop(); command on frame 30 of each MC.

              // this would be your code for frame 30



              //check if another card is already flipped

              if(_global.tempCard != undefined){

                   //if so do your match check function



                   //since this would be the first card flipped we set the global variable to the instance path

                   _global.tempCard = this;



              //in your checkCards function you will want to reset the _global.tempCard variable back to undefined.    

              // I would imagine your checkCards() function would look something like this

              function checkCards(){

                   //check if the faceValue (made up) is the same for each card

                   if(this.faceValue == _global.tempCard.faceValue){

                        //matching faces removes the cards




                        //mismatched faces flips the cards back over and sets the global var to undefined



                        _global.tempCard = undefined;




              I haven't had a chance to test this, but something similar to this should be able to get your card matching application working.

              • 4. Re: mc calling
                dn0myar06 Level 1

                ey thanks for replying...


                i tried your code...and its not too complicated to read than the others, but there seems to be a problem with

                card1_mc.onRelease = function(){

                     //flip the selected card  over




                the card automatically flipped even without clicking it...


                this is actually what i'm doing earlier...

                i made a movieclip...then i have a button with zero _alpha that attaches another movieclip when clicked...

                this is the code that i put in my button:


                on (release) {
                    if (_root.c == 0) {                       //i used c to know if this is the first time a card has been flipped
                        _root.combi = 1;                   //combi is a temp variable to assign the first card clicked
                    }else if (_root.c ==1) {
                        _root.combi2 = 1;                    //combi2 is for the 2nd card
                        _root.c = 0;
                        if (_root.combi == _root.combi2) {     //then i compare if they are equal
                            _root.wrong = 0;
                        }else {
                            _root.wrong = 1;
                        _root.combi = 0;
                        _root.combi2 = 0;

                        _root.c = 0;
                    var mc:MovieClip=attachMovie("1_1stpair","1_1stpair",getNextHighestDepth());          //1_1stpair is the mc that flips the cards


                then this is what i used on frame 30 of 1_1stpair mc:



                if (_root.wrong ==1) {


                its quite working, but the first card clicked doesn't check if wrong = 1....

                i tried a do,while loop but my pc crashed...lol


                i'm not sure what code to use, i'm not yet that well of using functions so i'm trying to do it brute force..lol

                maybe you could suggest something to put in my code..thanks!!!