我目前正在尝试将生成的XML(xmlResult)添加到舞台上的文本框中。我确实尝试使用MovieClip(root)。[instancename] .text = .....但它不起作用 - null对象引用?有什么建议?谢谢!
package {
public class ChatHistory extends MovieClip {
public function ChatHistory()
{
//constructor
}
public function getChatText() {
var loader:URLLoader = new URLLoader();
loader.addEventListener( Event.COMPLETE, requestComplete);
var requestURL:URLRequest = new URLRequest("http://localhost:80/chathistory.xml");
requestURL.method = URLRequestMethod.GET;
loader.load(requestURL);
}
private function requestComplete( event:Event ):void {
try {
var xmlResult:XML = new XML(event.target.data);
trace(xmlResult);
} catch ( e:TypeError ) {
trace(e.message);
}
}
}
}
答案 0 :(得分:0)
我试过这个并且它有效,也许这可以启发你:
import flash.text.TextField;
import ik_fla.MainTimeline;
TextField(MainTimeline(stage.getChildAt(0)).getChildByName('myTxt')).text = "weeee";
或者您可以通过使用imports
强制转换来避免Object
:
Object(Object(stage.getChildAt(0)).getChildByName('myTxt')).text = "weeee";