こんにちは、フレックスビルダーを初めて使用し、文字列のリストで構成される外部ファイルから配列を作成しようとしています。
どうすればいいですか?ある種のデータ オブジェクトを使用する必要がありますか?
こんにちは、フレックスビルダーを初めて使用し、文字列のリストで構成される外部ファイルから配列を作成しようとしています。
どうすればいいですか?ある種のデータ オブジェクトを使用する必要がありますか?
開始するための例を次に示します。
サンプル ファイル(file_with_strings.txt):
one, two, three
サンプルアプリ
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
initialize="initializeHandler()">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
protected function initializeHandler():void
{
service.send();
}
protected function updateList(result:Object):void
{
var array:Array = result.split(/,\s+/);
var collection:ArrayCollection = new ArrayCollection(array);
list.dataProvider = collection;
}
]]>
</mx:Script>
<mx:HTTPService id="service"
url="file_with_strings.txt"
resultFormat="text" result="updateList(event.result)"/>
<mx:List id="list"/>
</mx:Application>
クラスを使用しHTTPService
て外部ファイルをロードするだけです。resultFormat
必要に応じて、XML、オブジェクト、およびその他のいくつかのものに変更できます。updateList()
ただし、そのメソッドをカスタマイズするだけです。
お役に立てば幸いです、ランス