Sign in to follow this  
Serendipity

Another Simple Flash Question

Recommended Posts

Serendipity    122
I'm still working my way through Foundation Game Design with Flash. I've typed in another example as written and I'm getting yet another error message: 1046:Type was not found or was not a compile-time constant: TextFiled Source { Followed by the same error with the source import flash.display.MovieClip; The text for the input and output fields is also not showing. Any help would be appreciated. Here's my code: package { import flash.display.MovieClip; import flash.events.MouseEvent; public class Main extends MovieClip { var startMessage:String; var mysteryNumber:uint; public function Main() { init(); } function init():void { startMessage = "I am thinking of a number between 1 and 100"; mysteryNumber = 50; output.text = startMessage; input.text = ""; } } }

Share this post


Link to post
Share on other sites
aaronjbaptiste    100
I also think something is wrong with input and output.

Some question:

1) Where are you developing this? Flex IDE? Flash IDE?


Assuming it is Flash IDE:

2) There should be 2 TextFields on the stage. One with instance name "output" and the other "input". If this is correct then try Lostvoices advice and add stage before input and output.

In pure AS3 using Flex Builder the following code works fine:



package {
import flash.display.MovieClip;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;

public class Main extends MovieClip
{
public function Main()
{
var startMessage:String;
var mysteryNumber:uint;

var input:TextField = new TextField();
var output:TextField = new TextField();

input.autoSize = TextFieldAutoSize.LEFT;
output.autoSize = TextFieldAutoSize.LEFT;

addChild(input);
addChild(output);

startMessage = "I am thinking of a number between 1 and 100";
mysteryNumber = 50;

output.text = startMessage;
input.text = "";
}
}
}




Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this