Hi,
I am trying to work out a solution in Flash for making text input appear in two text boxes at the same time, hopefully in realtime.
Preferably I want to use actionscript 2 but I am willing to use either.
I know for a start I need to set the textbox to Input Text.
I found in the help for AS3 the section -> Programming ActionScript 3.0
Working with text > Capturing text input
However when I use this code it gives me the error “package cannot be nested”
Thanks for any suggestions/help it is really appreciated!
Here is the code in the help file:
package
{
import flash.display.Sprite;
import flash.display.Stage;
import flash.text.;
import flash.events.;
public class CaptureUserInput extends Sprite
{
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;
}
}
}