A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Trouble with making Pairs

  1. #1
    Member Manic_Man's Avatar
    Join Date
    Dec 2007
    Location
    Hastings, England
    Posts
    91

    Trouble with making Pairs

    Am trying to make a game of pairs (the old game where you have to match two cards that are the same) and i have done a function to turn over the card and check if you have two the same but there is a problem. It seams to remember the path for the First movie clip but once i have clicked on a second clip, it doesn't seam to store do anything with that. I'll post the function and then see if i can explain better.

    Code:
    function CardCheck(num){
    	//This Checks what card you have clicked on
    		_root.mc.Card.gotoAndStop(7);
    		_root.mc.Card.CardFront.gotoAndStop(_root.CardArray[num]);
    		
    		if (_root.CardClicks == 0){
    			_root.CardA = _root.CardArray[num];
    			_root.CardClicks = 1;
    			_root.PathA = _root.mc;
    		}
    		else if (_root.CardClicks == 1){
    				_root.CardB = _root.CardArray[num];
    				_root.CardClicks = 0;
    				_root.PathB = _root.mc;
    				if (_root.CardA == _root.CardB){
    					_root.PathA.Card.gotoAndPlay(2);
    					_root.PathB.Card.gotoAndPlay(2);
    				}
    				else
    				{
    					_root.PathA.Card.play();
    					_root.PathB.Card.play();
    				}
    		}
    	}
    Now, _root.mc is where set to be 'this' on the code for the movie clip in question so that should be the route of that clip. PathA should store the path for the first card movie object and PathB should be the second. Card is the name of a movie clip instead that clip which has the animations and such for the cards. Num is the number of the card and it checks with an array to what card image is set there. CardFront is the image that will be displayed on the card then it is turned. I don't think much more needs to be explained in that function. Just ask if you think i need to.

    For some reason, it works fine goes though the code BUT only seam to have the 'PathA' lines taking effect. PathB card just stays still as if nothing happens. When i debug, even the first line of changing the card's frame doesn't work. Any ideas? i am clueless.

    Well.. there is one clue. The code in the Movie clips that is being click on is:
    onClipEvent(mouseDown){
    if (hitTest( _root._xmouse, _root._ymouse, false)) {
    if (this.Card._currentframe == 1) {
    _root.mc = this;
    _root.CardCheck(1);
    }
    }
    }
    The number to pass to the CardCheck changes with whatever card number it is. I put the mouse checking that it is that clip being clicked because if i didn't, it fired no matter what has been clicked on.
    Last edited by Manic_Man; 02-29-2008 at 10:04 AM.

  2. #2
    Member Manic_Man's Avatar
    Join Date
    Dec 2007
    Location
    Hastings, England
    Posts
    91
    I have looked around, still no help. I have double checked my code and it is just on that second time that it can't seam to use the path stored. Am i just not storing it right or something? but then, it worked the first time and the second time is no different. I double checked to make sure there isn't some code firing in to reset the value and there isn't. I should be able to use difference instances of the SAME Movie Clip as long as i change the AS name each time so what is wrong?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center