Skip to main content
BluTurquoise
Participating Frequently
October 8, 2015
Question

score disappears in game

  • October 8, 2015
  • 2 replies
  • 677 views

to anyone whom can help:

this is a lesson I'm doing for a class except the tutorial doesn't cover the response to this scenario.  My score disappears once the game is in execution mode.  I've seen forms suggesting the placement of a .embed code (not specific where) I've also seen a suggestion to change font which i've done and nothing has happened.  I don't want to disrupt the code from the lesson to much so any suggestions to what I may be missing I appreciate.

thank you.

//Setting up the game variables

userChoice = "none";

userComp = "none";

//Setting up score variables

Wins = 0;

Losses = 0;

Draws = 0;

Tries = 0;

//control variable

control = true;

//Initial hideLogos call

hideLogos();

function hideLogos()

{

  //Hiding our logos

  this.StatWin._visible = false;

  this.statLose._visible = false;

  this.statDraw._visible = false;

}

//Choose functions

function choose(newChoice)

{

  //If we have control, run the game

  if (control)

  {

  hideLogos();

  userChoice = newChoice;

  trace("You've have selected " + userChoice);

  rndChoice = Math.ceil(Math.random() * 3);

  //trace ("Random number : " + rndChoice) ;

  switch (rndChoice)

  {

  case 1 :

  compChoice = "Rock";

  break;

  case 2 :

  compChoice = "Zors";

  break;

  case 3 :

  compChoice = "Paper";

  break;

  }

  trace("Computer selected" + compChoice);

  Object(this).scarecrowUser.gotoAndPlay(userChoice);

  Object(this).scarecrowComp.gotoAndPlay(compChoice);

  control = false;

  }

}

function gameLogic()

{

  if (!control)

  {

  if ((userChoice == "Rock" && compChoice == "Zors") || (userChoice == "Zors" && compChoice == "Paper") || (userChoice == "Paper" && compChoice == "Rock"))

  {

  //Result is victory

  trace("You've won!");

  this.StatWin._visible = true;

  wins++;

  }

  else if (userChoice == compChoice)

  {

  //Result is draw

  trace("it's a draw");

  Object(this).statDraw._visible = true;

  draws++;

  }

  else

  {

  //Result is loss

  trace("you've lost :(");

  Object(this).statLose._visible = true;

  losses++;

  }

  tries++;

  control = true;

}

}

//Functions for the buttons

Object(this).btnRock.onPress = function()

{

  choose("Rock");

};

Object(this).btnPaper.onPress = function()

{

  choose("Paper");

};

Object(this).btnZors.onPress = function()

{

  choose("Zors");

};

This topic has been closed for replies.

2 replies

Inspiring
October 10, 2015

As I see in the screenshot, the score text field has no instance name and in your code you're using trace only   trace("You've won!");.. that will not do anything to the score text field it'll only show you the result in the Flash output window! if I am not wrong you have to give an instance name for each text field you want to show your messages through it.. after that use the text fields names in the code to fill the text ( text_instance.text = "You've won!"; ) instead of trace("You've won!");.. plus the previews steps for the font.

Inspiring
October 8, 2015

Object(this).statLose._visible = true;

correct the "visible" code: statLose.visible = true; without underscore.

BluTurquoise
Participating Frequently
October 10, 2015

I tried pulling the underscore but unfortunately it still did not work.  There was another similar complaint where they changed the font and they were good.  I suspect it has something to do with Flash and the imbed radio button.

BluTurquoise
Participating Frequently
October 12, 2015

This is a simple tutorial on YouTube for Dynamic TextField it'll help if you like to watch it.

https://www.youtube.com/watch?v=LmSibzZbLNY

Regards.


After further review with a friend that has some coding experienced she

broke down for me what you were trying to explain to me as far as

correcting the code I was working with at this point I'm going to reference

the video you sent and also an email in regards to font and property use;

Some links that may help:

http://www.adobe.com/devnet/archive/flash/quickstart/embedding_fonts.html

http://www.adobe.com/devnet/flash/articles/avoiding-mistakes-text.html

Thank you for using Picture and Video Messaging by U.S. Cellular. See

www.uscellular.com for info.

I'm actually a beginner and it appears that the font was not setup properly

(as you were explaining as well) which forces me to be clueless. There

were a lot of things my friend pointed out that I had no idea as far as how

the code was calling on the font and how my code was setup… I'm going to

try and work on this a little at a time and this may be a while but I

really appreciate the help and if I am able to fix this I will respond to

my ticket in which you've been helping me.

Thank you