Skip to main content
Participant
February 24, 2015
Answered

Text box renders text as HTML...stop it!!!!!!

  • February 24, 2015
  • 1 reply
  • 300 views

Hi

I'm using AS 2 with Flash CS5.

Each year in my teaching interactivity in Flash, we get a few students who can't make this simple calculator work. I've included the code to show you what we're doing.

The problem is that one of the text boxes, instead of returning a number, returns HTML. You can see the problem when you trace the output from "answer" in the Output window.

We've checked that "Render text as HTML" is not clicked. I'd really like to hear of a resolution - maybe I can do this a better way!!! It seems so simple, yet, it always causes problems. Add I can't see why it does?

I'd appreciate any advice.

stop();

var a:Number = Math.round (Math.random ()*10);

var b:Number = Math.round (Math.random ()*10);

var score:Number = 0;

var sndTrack:Sound = new Sound();

var sndTrack2:Sound = new Sound();

trace(a+b);

check_btn.onRelease =function():Void {

  trace (answer);

  if (Number(answer) != (a+b))

  {

  e = ("Sorry, the answer was " + (a+b));

  sndTrack2.attachSound("gasp");

  sndTrack2.start();

  }

else

  {

  e = ("Well done, the answer was correct " + (a+b));

  sndTrack.attachSound("clap");

  sndTrack.start();

  score ++;

  }

}

next_btn.onRelease =function():Void{

  e = "";

  answer ="";

  a = Math.round (Math.random ()*10);

  b = Math.round (Math.random ()*10);

  Selection.setFocus("answer");

}

This topic has been closed for replies.
Correct answer kglad

oh, you're not rendering text.

you must be using the variable property of the textfield.  that's causing the problem; you should never use that.  use the textfield's text property.

1 reply

kglad
Community Expert
Community Expert
February 24, 2015

make sure kerning is unticked too.

basil_60Author
Participant
February 24, 2015

Always check for that first - to ensure they've "Used device fonts".

Thanks anyway

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
February 24, 2015

oh, you're not rendering text.

you must be using the variable property of the textfield.  that's causing the problem; you should never use that.  use the textfield's text property.