我不知道为什么这不起作用。我有一个tabnavigator,我动态添加一个导航容器,其中textarea动态添加到导航容器。两者的id都与chatguys [c] [0]具有相同的字符串名称。 它给出了错误,说'TypeError:错误#1034:类型强制失败:无法将spark.skins.spark :: SkinnableContainerSkin @ 9737851转换为spark.components.TextArea。“在运行时。确实如此?
任何帮助将不胜感激,谢谢:(
var idx:uint;
const len:uint = navigate.numChildren;
var alreadyexists:Boolean = false;
for (idx = 0; idx < len; idx++) {
//var check:spark.components.TextArea = navigate.getElementAt(idx) as spark.components.TextArea;
//var check:Tab = navigate.getTabAt(idx) as Tab;
var check:NavigatorContent = navigate.getChildAt(idx) as NavigatorContent;
// var check = navigate.getElementAt(idx);
//elmt.selected = tgBtn.selected;
if (check.label == evt.username)
{// trace(navigate.getChildAt(idx).label);
var c:uint;
const p:uint = chatguys.length;
for (c = 0; c < p; c++){
if(chatguys[c][0] == evt.username){
spark.components.TextArea(DisplayObjectContainer(navigate.getChildAt(idx)).getChildAt(chatguys[c][0])).textFlow=TextConverter.importToFlow(chatguys[c][1], TextConverter.TEXT_FIELD_HTML_FORMAT);
}}
b这里生病告诉你下半场工作正常,但也许我需要做不同的事情以获得我需要做的事情?
var chats:Array = [];
var chatguys:Array = [];
public function userlist_click() :void{
var windowname:Object =users_lst.selectedItem;
var idx:uint;
const len:uint = navigate.numChildren;
trace(navigate.numChildren);
var alreadyexists:Boolean = false;
for (idx = 0; idx < len; idx++) {
var check:NavigatorContent = navigate.getChildAt(idx) as NavigatorContent;
if (check.label == windowname.name)
{
alreadyexists = true;
}
}
if (alreadyexists == false)
{
chats[windowname.name] = new spark.components.TextArea();
chats[windowname.name].x = 10;
chats[windowname.name].y= 32;
chats[windowname.name].width= 517.19696 ;
chats[windowname.name].height= 343.18182;
chats[windowname.name].scroller
chats[windowname.name].x="9";
chats[windowname.name].y="2";
chats[windowname.name].width="517.19696";
chats[windowname.name].height="343.18182";
chats[windowname.name].setStyle("skinClass", spark.skins.spark.TextAreaSkin);
//textArea.skinClass= "spark.skins.spark.TextAreaSkin";
chats[windowname.name].text="ffg";
chats[windowname.name].setStyle("verticalScrollPolicy", ScrollPolicy.ON);
var match = new Array();
match.push(windowname.name);
match.push('bob');
chatguys.push(match);
for (var i in chatguys){
if (chatguys[i][0] == windowname.name){
chats[windowname.name].textFlow=TextConverter.importToFlow(chatguys[i][1], TextConverter.TEXT_FIELD_HTML_FORMAT);
}}
chats[windowname.name].id = windowname.name;
trace(chats[windowname.name]);
var messagebox:NavigatorContent = new NavigatorContent;
messagebox.percentWidth= 100;
messagebox.percentHeight= 100;
messagebox.label = chats[windowname.name];
messagebox.id = chats[windowname.name];
trace(messagebox.label);
messagebox.addElement(chats[windowname.name]);
navigate.addChild(messagebox); }}