I’m Currently creating an interactive video game.
There are 66 movies. I’m new to AS3 and have a little experience with AS2.
I will try to explain the game!
You choose from 5 ingredients, each has this product provides a number of calories:
[LIST]
[] Rice R = <- standard value!
[] Mais =-C
[] Roots =-W
[] Tofu-T =
[] Onions-U =
[] Champions =-M
[/LIST]
Each ingredient can be added only 1 once.
Good combinations:
[LIST]
[]R-U-T-C
[]R-U-C-T
[]R-T-U-C
[]R-T-U-C
[]R-C-U-T
[]R-C-T-U
[/LIST]
Each movie is in a movie clip. And the frame where the movieclip is on, is labeled with the combination.
For this I wrote the following script:
ActionScript 3 Code:
stop ();
var caloriesVar: Number = 10, / / default Rice
var inpanVar: String = "R", / / R = Rice
iLabel.info_txt.text = (caloriesVar);
iLabel.info_txt2.text = (inpanVar) / / idem
Click function handle (cEvent: MouseEvent): void (
if (cEvent.target == Carrots) (
trace ( "Carrot btn");
inpanVar = (inpanVar + "W") / /
caloriesVar = (caloriesVar + 15);
Carrots.enabled = false, / * because only 1 time can be clicked * /
Carrots.visible = false, / / ditto
iLabel.info_txt2.text = (inpanVar) / * To test if it works in the variable * /
iLabel.info_txt.text (caloriesVar) / / idem
gotoAndStop (inpanVar) / / go to correct frame
) Else if (== cEvent.target Union) (
trace ( "Union btn");
inpanVar = (inpanVar + "-U");
caloriesVar = (caloriesVar + 20);
Union.enabled = false;
Union.visible = false;
iLabel.info_txt2.text = (inpanVar);
iLabel.info_txt.text (caloriesVar);
gotoAndStop (inpanVar);
) Else if (== cEvent.target Corn) (
trace ( "Corn btn");
inpanVar = (inpanVar + "C");
caloriesVar = (caloriesVar + 25);
Corn.enabled = false;
Corn.visible = false;
iLabel.info_txt2.text = (inpanVar);
iLabel.info_txt.text (caloriesVar);
gotoAndStop (inpanVar);
) Else if (cEvent.target == Mushroom) (
trace ( "Mushroom btn");
inpanVar = (inpanVar + "-M");
caloriesVar = (caloriesVar + 30);
Mushroom.enabled = false;
Mushroom.visible = false;
iLabel.info_txt2.text = (inpanVar);
iLabel.info_txt.text (caloriesVar);
gotoAndStop (inpanVar);
) Else if (cEvent.target == Tofu) (
trace ( "Tufo");
inpanVar = (inpanVar + "-T");
caloriesVar = (caloriesVar + 35);
Tofu.enabled = false;
Tofu.visible = false;
iLabel.info_txt2.text = (inpanVar);
iLabel.info_txt.text (caloriesVar);
gotoAndStop (inpanVar);
)
)
But this does not work. When you click a button, the script doesn’t do anything. Do not know where it goes wrong because he does not update the text fields. To me it seems like he doesn’t uses the function, or maybe something else is wrong?
I hope, I explained it well.
Could someone please help me with this?
Thanks in advance!