
Export your .aia file and upload it here.
In clock1.timer, test those two variables firstflip and secondflip for -1 before trying to use them as card components.
Sometimes it is easier to generalize a problem that do deal with individual cases.
For your two variables firstFlipped and SecondFlipped, they could be replace with a single global list Flipped, initially an empty list.
Each time you want to go flip a card, check the length of the list. If under 2, it's okay to flip a card (button) and then add it to the list.
Then the length of the list can tell you if you have enough cards flipped to checking them for matches.
To unflip all your cards, loop through the Flipped list before emptying it.