你制作了一个字符串变量。和 stageText 添加更改事件。text
并在发生事件时存储 stageText 属性。稍后使用 String 变量。
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.geom.Rectangle;
import flash.text.ReturnKeyLabel;
import flash.text.SoftKeyboardType;
import flash.text.StageText;
import flash.events.Event;
var str:String;
var stageText:StageText = new StageText();
stageText.softKeyboardType = SoftKeyboardType.NUMBER;
stageText.restrict = "0-9";
stageText.returnKeyLabel = ReturnKeyLabel.GO;
stageText.stage = this.stage;
stageText.viewPort = new Rectangle(10, 10, 300, 40 );
stageText.addEventListener(Event.CHANGE, onChange);
function onChange(e:Event):void
{
str = stageText.text;
trace(str);
}