Class object help.
Hello, once again I am in need of some help.
I have two classes,
1.) Tile.as class - for a tic tac toe game which creates the acutal tile for the grid
2.) Game.as class - which implements and creates instances of the Tile class puts them on a grid, checks the turn, if there is a solution, and what to do with solution.
I assign questions to each square of the grid much like hollywood squares. If they get the question wrong the opposing teams shape will fill into the grid the user clicked on. My Problem is erratic behavior in setting the right shape into the grid squares. I set a switch case which goes through all the shapes marked, not what I want.
In Tile.as
//Game.isClicked is the e.CurrentTarget found in the game class.
//Game.isClicked.isSet is a string value that checks and makes sure the values are all the same inorder to solve.
public function updateGraphic(e:Event){
switch(Game.isClicked.isSet){
case "X":
tileO.visible = true;
tileX.visible = false;
Game.isClicked.isSet = "O";
Game.isClicked.isSet = "not set";
break;
case "O":
tileO.visible = false;
tileX.visible = true;
Game.isClicked.isSet = "X";
trace("update O after",Game.isClicked.name, Game.isClicked.isSet);
Game.isClicked.isSet = "not set";
break;
}
}
}
In Game.as
//this code is placed on 2 check boxes called "right" or "wrong" obj being called is e.currentTarget.name
public static function checkMark(obj:Object)
{
Tile.activateMouse(questBox,Tile.questionEvent);
switch (obj)
{
case "right" :
TweenMax.to(questBox.feedRight,.5,{autoAlpha:1});
break;
case "wrong" :
isClicked.dispatchEvent(new Event("updateGfx"));
TweenMax.to(questBox.feedWrong,.5,{autoAlpha:1});
break;
}
}
When applied in this manner if two questions have been answered one of which being the wrong answer, both will still go through the Tile.as case statment and reset based on the conditions.
Example: Question 1 shape was Wrong and set to O and Question 2 shape was Wrong and set to X. Once condition is called the O will be set to X in Question 1 Square and the X will be set to O in Question 2 Square.
I hope this explains things a bit, and any help/ideas would be greatly appreciated. Thank you.
