Skip to main content
Participant
April 13, 2016
Question

why does actionscript mess up strings

  • April 13, 2016
  • 1 reply
  • 311 views

import flash.utils.Timer;

import flash.events.MouseEvent;

import flash.media.Sound;

import flash.media.SoundChannel;

var nCount: Number = 0;

var saying: String = (" welcome to the game");

var warning: String = (" Hurry 5 seconds till next question! ");

var ending: String = (" time has run out hope you had fun");

var score: Number = 0;

var answer: String = ("red square");

var answer2: String = ("blue polygon");

var answer3: String = ("green circle");

var answer4: String = ("gray triangle");

var userInput: String;

var shapes: Array = [sqr_mc, tri_mc, cir_mc, poly_mc];

var myTimer: Timer = new Timer(1000, nCount);

guess_txt.border = true;

var audio: Sound = new Mission();

var channel: SoundChannel = new SoundChannel();

timer_txt.text = nCount.toString();

myTimer.start();

timer_txt.border = true;

score_txt.border = true;

myTimer.addEventListener(TimerEvent.TIMER, count);

function count(e: TimerEvent): void {

  nCount++;

  timer_txt.text = ("Time:" + nCount.toString());

  if (nCount == 1) {

  response_txt.text = (saying);

  } else if (nCount == 5) {

  ques_txt.text = "What is color and shape shown ?";

  } else if (nCount == 10) {

  myTimer.stop();

  response_txt.text = (ending);

  channel.stop();

  }

}

guess_btn.addEventListener(MouseEvent.CLICK, testInput);

function testInput(e: MouseEvent) {

  userInput = guess_txt.text;

  if (userInput == answer || userInput == answer2 || userInput == answer3 || userInput == answer4) {

  response_txt.text = "correct";

  score += 10;

  score_txt.text = ("Score:" + score.toString());

  } else if (userInput != answer || userInput != answer2 || userInput != answer3 || userInput != answer4) {

  response_txt.text = "incorrect Try again. ";

  score -= 5;

  score_txt.text = (score.toString());

  }

}

reset_btn.addEventListener(MouseEvent.CLICK, resetGame);

function resetGame(e: MouseEvent) {

  nCount = 0;

  myTimer.reset();

  timer_txt.text = ("Time:" + nCount.toString());

  channel.stop();

  score = 0;

  score_txt.text = ("Score:" + score.toString());

}

play_btn.addEventListener(MouseEvent.CLICK, playGame);

function playGame(e: MouseEvent) {

  myTimer.start();

  timer_txt.text = ("Time:" + nCount.toString());

}

audio_btn.addEventListener(MouseEvent.CLICK, playAudio);

function playAudio(e: MouseEvent) {

  var audio: Sound = new Mission();

  var channel: SoundChannel = new SoundChannel();

  channel = audio.play()

}

i have that code and when i test my movie action script messes up the strings and only displays i o u and a's .. can any one help

This topic has been closed for replies.

1 reply

Ned Murphy
Legend
April 13, 2016

Embed the fonts in your textfields.  Anytime you have text issues, first be sure to embed the fonts in the textfields.

Participant
April 13, 2016

how would go about embedding the fonts with what i have there ?

Ned Murphy
Legend
May 21, 2016

It appears the textfield is not being added dynamically, so for what you have there, go to the stage and select the textfield and in the Properties panel for the textfield select the option to Embed the font.  Then select the font and the character set(s) you expect to be included in the textfield.