Skip to main content
jdaston
Known Participant
July 31, 2015
Question

error 1120 and 1180 when trying to display number on the stage.

  • July 31, 2015
  • 1 reply
  • 917 views

Hello, I am trying to develop a program that will place random numbers on the stage and ask the user what is the difference, sum, product, etc.  The program so far is as follows:

import flash.display.MovieClip;
import flash.text.TextField;

function randomNumber(low:Number, high:Number):Number
{
  return Math.floor(Math.random() * (1+high-low)) + low;
}

var add1rand:int = randomNumber(0, 10);
radnum_txt:text = format(add1rand);

The numbers get generated but when I try to display them I get the following error:

Scene 1, Layer 'Layer 1', Frame 1, Line 10 1120: Access of undefined property text.

Scene 1, Layer 'Layer 1', Frame 1, Line 10 1180: Call to a possibly undefined method format.

I have been trying for two weeks and reviewed comments from the adobe community and google searches.  My system uses an AMD Phenom 9950, Quad core processor with 8GB of ram and the hard drive is a convair 128 SSD.  The operating system is Windows 7 with SP1, and the flash program is Flash professional CS6, ver. 12.0.2.529.  Thank you. 

This topic has been closed for replies.

1 reply

Ned Murphy
Legend
July 31, 2015

What code are you using to try to display them?  What code are you suing to format the text?

jdaston
jdastonAuthor
Known Participant
July 31, 2015

I am using the radnum_txt:text = Format (add1rand); alond with a movie clip symbol based on a text box with an iinstance name of radnum_txt.

Ned Murphy
Legend
July 31, 2015

To assign text to the textfield you use the dot notation.  You appear to be using a colon instead

radnum_txt.text =

as far as the format() function call goes, unless you are intending it from some other class, it is a method of the CurrencyFormatter class.  So you likely need to import that class to make use of it, and you don't appear to be utilizing it with a CurrencyFormatter object instance in any way either.

import flash.globalization.CurrencyFormatter;

Check out the class thru the following page as well as the format() method it explains...

CurrencyFormatter - Adobe ActionScript® 3 (AS3 ) API Reference