我在绑定数据时遇到了一些麻烦。Flex - 数据绑定不起作用
我有一个包含组件视图的应用程序。 假设我在viewstack中有comp1,comp2和comp3。 每个组件都有其自己的数据类 - > comp1Data.as,comp2Data.as和comp3Data.as。 每个组件中的所有值都绑定到其数据对象中的相应数据。
单击comp1中的控件导致comp3,comp2也是如此。点击comp2中的控件导致comp3。 从comp1到comp3时,comp3Data.as被初始化,而comp3显示绑定的值。 当从comp2到comp3,comp3Data.as也初始化,但绑定值不显示...
我试过使用初始化,但它不工作。在调试时,数据就在那里,但不显示。
任何帮助将非常感激。 问候,
BS_C3
一些代码^ __^ 主要应用:
<mx:Application>
<mx:Script>
<![CDATA[
private function order(s:String):void
{
if(s == 'order')
OrderData.instance.state = 'order';
else if(s == 'reporting')
{
OrderData.instance.state = 'reporting';
.
.
.
}
pages.selectedChild = or;
}
]]>
</mx:Script>
<mx:ViewStack id="pages" horizontalCenter="0" verticalCenter="0" width="100%" height="100%">
<components:SearchResult id="sr" width="100%"
order="order('order')"
/>
<components:Reporting id="rp" width="100%"
reportingOrder="order('reporting')"/>
<components:Order id="or" width="100%"
/>
</mx:ViewStack>
</mx:Application>
两个信息搜索结果和报告存取权限秩序。
Order.mxml看起来是这样的:
<mx:Canvas>
<mx:HBox width="100%">
<mx:Box paddingBottom="15" paddingLeft="15" paddingRight="15" paddingTop="15" backgroundColor="#FFFFFF" height="100%">
<components:OrderView id="ov"/>
</mx:Box>
<mx:Spacer width="15"/>
<components:OrderedSDR id="sdr" height="100%"/>
</mx:HBox>
</mx:Canvas>
我越来越烦恼与OrderedSDR.mxml:
<mx:Canvas>
<mx:VBox width="100%" height="100%" paddingBottom="28" paddingLeft="28" paddingRight="28" paddingTop="28" backgroundColor="#FFFFFF">
<mx:HBox width="100%" paddingBottom="6" horizontalAlign="center">
<mx:Canvas>
<mx:Image id="thumbnailBG" source="@Embed(source='assets/Images/SearchResult/BoxBagueOverview.PNG')"/>
<mx:Image id="overview" source="{GlobalData.instance.collection.overview.toString()}"/>
<mx:Label id="thumbnailCarats"
text="{GlobalData.instance.collection.carats.toString() + GlobalData.instance.languageProperties.orderedSDR.imageInfo.toString()}"
styleName="OVLBL"
paddingBottom="5" paddingRight="10"
x="{thumbnailBG.x + thumbnailBG.width - thumbnailCarats.width}"
y="{thumbnailBG.y + thumbnailBG.height - thumbnailCarats.height}"/>
</mx:Canvas>
</mx:HBox>
<mx:VBox id="mainBox" paddingBottom="8" paddingTop="8" verticalGap="6" width="180">
<mx:HBox width="100%" height="13">
<mx:Label width="80"
text="{GlobalData.instance.languageProperties.orderedSDR.product.toString()}"
styleName="OVDataLbl" opaqueBackground="#ECE5E2"/>
<mx:Label text="{SearchResultData.instance.selectedSDR.matnr_fp}" styleName="OVData"/>
</mx:HBox>
<mx:HBox width="100%" height="13">
<mx:Label width="80"
text="{GlobalData.instance.languageProperties.orderedSDR.netPrice.toString()}"
styleName="OVDataLbl" opaqueBackground="#ECE5E2"/>
<mx:Label text="{SearchResultData.instance.selectedSDR.currSymbol + ' ' + SearchResultData.instance.selectedSDR.fNet_price_fp}" styleName="OVData"/>
</mx:HBox>
.
.
.
</mx:VBox>
</mx:VBox>
</mx:Canvas>
里面mainBox,我有横向盒的列表具有相同的结构如前两个Hboxes所示。
关于数据源,这些都是下面的数据源,我使用,他们的预期行为和实际行为:
@
Embed(source='assets/Images/SearchResult/BoxBagueOverview.PNG --> The image is displayed as it should
GlobalData.instance.collection.overview.toString() --> GlobalData.instance.collection is a XMLList that contains the data for the image with id="overview". I do get the correct source, but the image is not displayed.
GlobalData.instance.languageProperties. ... --> It's a XMLList. The data is shown as it should.
SearchResultData.instance.selectedSDR.matnr_fp --> SearchResultData.instance.selectedSDR is an object that contains all the data that has to be displayed. Matnr_fp is a property of this object. And each hbox inside mainbox have to display a property of the object selectedSDR. The only property that is being displayed is SearchResultData.instance.selectedSDR.currSymbol. The other properties are not displaying even if the datasource is populated.
希望这将是有益的。 谢谢!
问候, BS_C3
你能发表一些代码吗?很难跟踪你的代码实际在做什么。 – bedwyr 2010-05-04 00:12:06
除非您发布您的代码,否则任何帮助都将是不可思议的。 – Robusto 2010-05-04 00:23:04