Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flash 如何在AS3中访问动态TextArea值?_Flash_Actionscript 3 - Fatal编程技术网

Flash 如何在AS3中访问动态TextArea值?

Flash 如何在AS3中访问动态TextArea值?,flash,actionscript-3,Flash,Actionscript 3,我已经创建了一个动态文本区域,希望检索该值并显示在跟踪中。 要运行下面的代码,必须将TextArea组件拖到后台 import fl.controls.TextArea; var totalTextArea=5; //Create multiple textarea for(var a:int = 0; a<totalTextArea; a++){ var cta:TextArea = new TextArea(); cta.move(300,

我已经创建了一个动态文本区域,希望检索该值并显示在跟踪中。 要运行下面的代码,必须将TextArea组件拖到后台

import fl.controls.TextArea; 
var totalTextArea=5;
     //Create multiple textarea
for(var a:int = 0; a<totalTextArea; a++){
        var cta:TextArea = new TextArea(); 
        cta.move(300,0+(a*100)); 
        cta.setSize(100, 60); 
        cta.condenseWhite = true; 
        cta.htmlText = a+'TextAreaA TextAreaB TextAreaC TextAreaD';  
        cta.name="TA"+a
        addChild(cta);
        trace(cta.text)
        cta.addEventListener(MouseEvent.CLICK, ShowCurrentValue);

}
//accessing TextArea 
function ShowCurrentValue(evt:MouseEvent):void{
        for(var b:int = 0; b<totalTextArea; b++){
            trace("somethingheere.txt")
        }
导入fl.controls.text区域;
var totalTextArea=5;
//创建多个文本区域

对于(var a:int=0;a我想您正在文本区域中单击

function ShowCurrentValue(evt:MouseEvent):void
{
    var textArea:TextArea = (evt.target as TextArea);
    trace(textArea.name + ": " + textArea.htmlText);        
}
如果要列出所有文本区域,我建议您在创建过程中将它们放入数组中,并在数组中迭代:

import fl.controls.TextArea; 
var totalTextArea = 5;
var textAreas:/*TextArea*/Array = [];

//Create multiple textarea
for(var a:int = 0; a<totalTextArea; a++)
{
    var cta:TextArea = new TextArea(); 
    cta.move(300,0+(a*100)); 
    cta.setSize(100, 60); 
    cta.condenseWhite = true; 
    cta.htmlText = a+'TextAreaA TextAreaB TextAreaC TextAreaD';  
    cta.name="TA"+a
    addChild(cta);
    trace(cta.text)
    cta.addEventListener(MouseEvent.CLICK, ShowCurrentValue);

    // add to array
    textAreas.push(cta);
}
//accessing TextArea 
private function ShowCurrentValue(evt:MouseEvent):void
{
    for(var b:int = 0; b < textAreas.length; b++)
    {
        var textArea:TextArea = textAreas[b] as TextArea;
        trace(textArea.name + ": " + textArea.htmlText);
    }
}
导入fl.controls.text区域;
var totalTextArea=5;
变量TextArea:/*TextArea*/Array=[];
//创建多个文本区域

对于(var a:int=0;a您是否尝试过textArea.text或textArea.htmlText?