views:

96

answers:

1

Hi!

I'm having some troubles with binding data.

I have an application that contains a viewstack of components. Let's say I have comp1, comp2 and comp3 inside the viewstack. Each component, has its own data class --> comp1Data.as, comp2Data.as and comp3Data.as. All values in each component are binded to the corresponding data in it's data object.

A click in a control in comp1 leads to comp3, the same goes for comp2. Clicking a control in comp2 leads to comp3. When going from comp1 to comp3, comp3Data.as is initialized and and comp3 displays the binded values. When going from comp2 to comp3, comp3Data.as is also initialized but the binded values are not displayed...

I tried using an initialize but it is not working. And when debugging, the data is right there, but it's is not displaying.

Any help would be really appreciated. Regards,

BS_C3


Some code ^__^ Main application:

<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>

Both SearchResult and Reporting acces Order.

Order.mxml looks like this:

<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>

I'm getting troubles with 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>

Inside mainBox, I've got a list of hbox with the same structure as shown in the first two Hboxes.

Regarding the datasources, these are the following datasources that I'm using, their expected behaviour and their actual behaviour:

@

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.

Hope this will be useful. Thanks!

Regards, BS_C3

A: 

Hi!!!

Looks like nobody's seen anything wrong with the code?? Me neither. But doing other modifications on the code, it finally worked. Still don't know why... >_<

BS_C3