플렉스 3줄 단위로 텍스트를 분할하는 방법
나는 TextArea 객체를 만들었습니다. 그런 다음 텍스트를 입력했습니다. 그런 다음이 텍스트에서 TextArea.text 속성을 사용합니다.
줄마다 가져온 텍스트를 어떻게 분할하고 문자열 배열로 변환 할 수 있습니까?
플렉스 3줄 단위로 텍스트를 분할하는 방법
나는 TextArea 객체를 만들었습니다. 그런 다음 텍스트를 입력했습니다. 그런 다음이 텍스트에서 TextArea.text 속성을 사용합니다.
줄마다 가져온 텍스트를 어떻게 분할하고 문자열 배열로 변환 할 수 있습니까?
"\ n"이 작동하지 않으면 "\ r"(캐리지 리턴)을 시도하십시오.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="onCreationComplete(event)">
<mx:Script>
<![CDATA[
import mx.events.CollectionEvent;
import mx.collections.ArrayCollection;
import mx.events.FlexEvent;
[Bindable]
private var ac:ArrayCollection;
protected function onCreationComplete(event:FlexEvent):void
{
ac = new ArrayCollection();
ac.addEventListener(CollectionEvent.COLLECTION_CHANGE, onCollectionChange);
}
protected function onKeyUp(event:KeyboardEvent):void
{
ac.source = event.target.text.split("\r");
}
protected function onCollectionChange(event:CollectionEvent):void
{
contents.text = ac.source.join("\r");
}
]]>
</mx:Script>
<mx:TextArea id="input" x="19" y="22" width="273" height="175" keyUp="onKeyUp(event)" />
<mx:TextArea id="contents" x="112" y="249" width="180" height="175" editable="false" />
<mx:Label x="19" y="222" text="Array Length:" fontWeight="bold" />
<mx:Label x="37" y="250" text="Contents:" fontWeight="bold" />
<mx:Label x="111" y="222" text="{ac.length}" />
</mx:Application>
는 희망이 도움이 : 그냥 상자에 입력하면 배열의 내용이 변경 볼 수 있습니다 - 여기 그것이 작동 줄 방법을 보여주는 몇 가지 코드입니다!
"줄로 나누기"란 무엇을 의미합니까? 보통은 textwidth 앞에있는 마지막 공백을 찾기 위해 텍스트를 스캔하고 그 라인을 호출하는 것입니다.
여러 줄 문자를 각 요소가 별도의 줄 (텍스트 문자열?) 인 – simplemagik
this site에 따르면 줄 바꿈 공급 문자는 "\ n"입니다. "\ n"과 함께 Split() 함수를 사용하면 문자열을 줄 바꿈으로 구분 된 문자열 배열로 나눌 수 있어야합니다.
문자열 배열로 변환해야합니다.이 문제를 해결하기위한 첫 번째 생각이었습니다. 그러나 그것은 효과가 없습니다! – simplemagik
감사합니다. !!! 그것은 내가 필요한 것입니다! – simplemagik