0

我有一个在我的手机上工作的 stageText 对象。我可以在该字段中输入并显示文本。如何捕获输入文本并将其存储在变量中以备后用?谢谢你。

var qatAccessCode:StageText = new StageText();
qatAccessCode.softKeyboardType = SoftKeyboardType.NUMBER;
qatAccessCode.restrict = "0-9";
qatAccessCode.returnKeyLabel = ReturnKeyLabel.GO;
qatAccessCode.stage = this.stage;
qatAccessCode.viewPort = new Rectangle(225, 765, 200, 35 );
4

1 回答 1

2

你制作了一个字符串变量。和 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);
}
于 2012-09-01T03:19:05.523 回答