如何读取flex循环中的line值

时间:2013-01-09 05:05:29

标签: flash flex adobe

我是flex开发的新手。我试图完成它似乎非常基本的PHP我的背景是。我想要做的是获取我从textarea读取的一行的价值。我在读取行时没有问题但是在运行循环时我无法获得它的值。代码如下。如果有人可以提供帮助,我会非常感激

var composer:StandardFlowComposer = txtSource.textFlow.flowComposer as StandardFlowComposer;
            for each (var line:TextFlowLine in composer.lines){ 
                trace(line); 
                     }  

2 个答案:

答案 0 :(得分:1)

根据我从文档中可以看出,

“lines”不是StandardFlowComposer的属性。您需要使用getLineAt(int)来读取一行。所以,像这样:

var composer:StandardFlowComposer = txtSource.textFlow.flowComposer as StandardFlowComposer;
for (var i:int = 0; i < composer.numLines; i++){ 
    trace(composer.getLineAt(i)); 
}

答案 1 :(得分:1)

var composer:StandardFlowComposer = txtSource.textFlow.flowComposer as StandardFlowComposer;



 var dlim:int=0;
for each (var line:TextFlowLine in composer.lines)
{ 
        var text:String = txtSource.text.slice(dlim,dlim+line.textLength);
        dlim=dlim+line.textLength;
        trace(text);
}