anyway, theres probably something simple I’m overlooking here, but it is a bit of a complicated script.
Its a memory card game and when _root.turn = “computer” it should run through the computers script, but it doesn’t even get the first block, and the if loops might be a little shaky.
Functions
contains = function (input, arrayData) {
for (i=0; i<arrayData.length; i++) {
if (arrayData* == input) {
return 1;
}
}
return -1;
};
index = function (input, arrayData) {
for (n=0; n<arrayData.length; n++) {
if (arrayData[n] == input) {
return n;
}
}
};
Memory = ["none"];
if (_root.turn == "computer") {
pick = random(7);
if (Card[pick].matched != true) {
Card[pick].gotoAndStop(2);
_root.Match = Card[pick].colour;
_root.LastMatch = Card[pick];
if (Card[pick]._currentframe == 7) {
if (contains(Card[pick].matchy, Memory) == 1) {
chance = random(100);
if (chance<((100-10)-index(Card[pick].matchy, Memory))) {
Card[pick].matched = true;
Card[pick].matchy.matched = true;
Card[pick].gotoAndPlay(3);
Card[pick].matchy.gotoAndPlay(3);
compscore += 1;
} else {
picky = Card[random(7)];
if (picky.matched != true) {
if (Card[pick].matchy == picky) {
Card[pick].matched = true;
Card[pick].matchy.matched = true;
Card[pick].gotoAndPlay(3);
Card[pick].matchy.gotoAndPlay(3);
compscore += 1;
} else {
Card[pick].gotoAndPlay(8);
picky.gotoAndPlay(8);
_root.turn = "player";
}
}
}
}
}
}
}
and you might want the card codes well to get some of the variables, each card has the same script except for the colours and matches
onClipEvent (load) {
stop();
var colour = "green";
var matchy = _root.CardGreen2;
var matched = false;
}
on (release) {
Memory.splice(index(this, Memory), 1);
Memory.unshift(_root.CardGreen1);
if (_root.Match == "Green") {
this.gotoAndPlay(3);
_root.CardGreen2.gotoAndPlay(3);
_root.Match = "none";
_root.Score += 1;
this.enabled = false;
this.matched = true;
_root.CardGreen2.enabled = false;
_root.CardGreen2.matched = true;
} else {
if (_root.Match != "none") {
gotoAndPlay(8);
_root.LastMatch.gotoAndPlay(8);
_root.Match = "none";
this.enabled = true;
_root.LastMatch.enabled = true;
_root.LastMatch = "none";
_root.turn = "computer";
} else {
gotoAndStop(2);
_root.Match = "Green";
_root.LastMatch = this;
this.enabled = false;
}
}
}