要件がある場合、必要なフレックスバージョンですか?最新のFlex 4コードを使用していますか?一般的に言えば、これはFlexでの非常に簡単な作業です。AnEntry.mxmlのMXMLでクラス定義を作成します。これはTextInput(またはラベルとTextInputなど、各エントリに必要なもの)です。 Flex 3のボタンのクリックハンドラでthis.addChild(new AnEntry())またはFlex 4でthis.addElement(new AnEntry());を呼び出します。送信するには、0から開始してthis.numChildrenに行くループと、各TextInputのループをHTTPServiceのparamsとして渡します。フレックス3.4
[AnEntry.mxml]
<?xml version="1.0" encoding="utf-8"?>
<mx:Box xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Label text="Link:"/>
<mx:TextInput id="theTextInput"/>
</mx:Box>
[MainApplication.mxml]
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
minWidth="955"
minHeight="600">
<mx:Script>
<![CDATA[
import mx.rpc.http.HTTPService;
protected function button1_clickHandler(event:MouseEvent):void
{
var params:Object = {};
var paramCount:Number=0;
// TODO Auto-generated method stub
for(var i:Number = 0; i<numChildren; i++)
{
var currentChild:DisplayObject = getChildAt(i);
if(currentChild is AnEntry)
{
params[paramCount++] = (currentChild as AnEntry).theTextInput.text;
}
}
var httpService:HTTPService = new HTTPService();
httpService.method = "POST"
httpService.url = "http://www.shaunhusain.com/somewhere.php";
httpService.send(params);
}
]]>
</mx:Script>
<mx:Button label="Add Entry" click="this.addChild(new AnEntry())"/>
<mx:Button label="Submit Info" click="button1_clickHandler(event)"/>
</mx:Application>
に対してコンパイル以下
2つのファイルが、これはあなたが行く取得する場合、私に知らせてください。 Flexの1週間の動画検索の初心者であれば、Flex開発を開始する上で参考になる素晴らしいチュートリアルです。 Flexの4のための
改正:
[MainApplication.mxml]
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
<s:layout>
<s:VerticalLayout/>
</s:layout>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.rpc.http.HTTPService;
protected function button1_clickHandler(event:MouseEvent):void
{
var params:Object = {};
var paramCount:Number=0;
// TODO Auto-generated method stub
for(var i:Number = 0; i<numChildren; i++)
{
var currentChild:DisplayObject = getChildAt(i);
if(currentChild is AnEntry)
{
params[paramCount++] = (currentChild as AnEntry).theTextInput.text;
}
}
var httpService:HTTPService = new HTTPService();
httpService.method = "POST"
httpService.url = "http://www.shaunhusain.com/somewhere.php";
httpService.send(params);
}
]]>
</fx:Script>
<mx:Button label="Add Entry" click="this.addElement(new AnEntry())"/>
<mx:Button label="Submit Info" click="button1_clickHandler(event)"/>
</s:Application>
[AnEntry.mxml]
<?xml version="1.0" encoding="utf-8"?>
<mx:Box xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<mx:Label text="Link:"/>
<mx:TextInput id="theTextInput"/>
</mx:Box>
私は物事を複雑にされたと思います。とにかく、あなたのコードは間違いなく正しい方向に私を指摘しました。 Sparkを反映させるために小さな変更を加えてFlex 4でコードを実行しましたが、期待通りにビジュアル要素をコンテナに追加していませんでした。何か不足していますか?知恵を共有してくれてありがとう。 – Jay
Flex 4でも動作するはずですが、addChildをaddElementに変更するだけで済むと思います。 – shaunhusain
Flex 4.0用にコンパイルされたバージョンを含めるように編集しましたが、まだ問題があるように見える場合はお知らせください。 – shaunhusain