回到AS3并使用textinput卡住了,当我跟踪文本变量时,输出窗口显示为null?
该变量名为stext:String,捕获文本函数返回null?
package {
//Import Statements
import flash.display.MovieClip;
import flash.events.*;
import flash.text.TextField;
public class MyAppMain extends MovieClip {
/* --------------
DECLARE VARIABLES
---------------*/
var search:MovieClip;
var searchText:MovieClip;
var stext:String;
public function MyAppMain() {
// constructor code
loadSearch(); //CALL LOADSEARCH FUNCTION
}
function loadSearch(){
//LOAD SEARCH BUTTON
search = new Search_btn;
search.x = 10;
search.y = 10;
search.buttonMode = true;
addChild(search);
search.addEventListener(MouseEvent.CLICK, test);
//LOAD TEXT AREA
searchText = new SearchText_txt;
searchText.x = 10;
searchText.y = 50;
addChild(searchText);
}
function test(e:MouseEvent):void{
captureText();
trace ("I have arrived at test")
}
function captureText():void{
stext = searchText.text;
trace ("Answer" +stext);
}
}
}