Hmm. I copy & pasted the code into a new ActionScript project in Flash Builder. It compiled and ran with no problems.
I'm not sure what to say. Maybe double-check that you copied the whole thing. Also, I ran it in a browser. Are you trying it in AIR or on a device?
HTH,
Randy Nielsen
Senior Content and Community Lead
Would really like to get a solution to this problem have tried again on a brand new file with the above code and I get error 1037 Package can not be nested. I have spend days trying to get a basic capture text input frame and everything on the net comes up with a similar message usually to do with not being possible to nest package. Im using Flash professional CS5.5 to be exact. Im pretty new to this software. Would really appreciate some suggestions. Im using a MacBook Pro. All help greatfully received
I looked at the instructions for running class-based AS examples and noticed one thing. They say that to run in Flash Pro, you must inherit from Sprite, not MovieClip. So try adding an import and extend from MovieClip, something like this:
import flash.display.MovieClip;
public class CaptureUserInput extends MovieClip
Hope this helps,
-Randy
Thanks again for your assistance apologies for the delay getting back. Im
afraid still no success. I created a folder on my desktop and called it
Text Capture Flash. Into this folder I created and saved a CS5.5 file
called CaptureUserinput.fla and another called CaptureUserinput.as
Now I updated the Document class as follows;
package
{
import flash.display.MovieClip;
import flash.display.Stage;
import flash.text.*;
import flash.events.*;
public class CaptureUserInput extends MovieClip
{
private var myTextBox:TextField = new TextField();
private var myOutputBox:TextField = new TextField();
private var myText:String = "Type your text here.";
public function CaptureUserInput()
{
captureText();
}
public function captureText():void
{
myTextBox.type = TextFieldType.INPUT;
myTextBox.background = true;
addChild(myTextBox);
myTextBox.text = myText;
myTextBox.addEventListener(TextEvent.TEXT_INPUT,
textInputCapture);
}
public function textInputCapture(event:TextEvent):void
{
var str:String = myTextBox.text;
createOutputBox(str);
}
public function createOutputBox(str:String):void
{
myOutputBox.background = true;
myOutputBox.x = 200;
addChild(myOutputBox);
myOutputBox.text = str;
}
}
}
Alas when I tested the movie while this time there were no error messages
(Progress I must admit), there was no text box just a blank swf.
North America
Europe, Middle East and Africa
Asia Pacific