Reference Nested Components : XML data « Data Model « Flex






Reference Nested Components

Reference Nested Components
           

<!--
Code from Flex 4 Documentation "Using Adobe Flex 4".

This user guide is licensed for use under the terms of the Creative Commons Attribution 
Non-Commercial 3.0 License. 

This License allows users to copy, distribute, and transmit the user guide for noncommercial 
purposes only so long as 
  (1) proper attribution to Adobe is given as the owner of the user guide; and 
  (2) any reuse or distribution of the user guide contains a notice that use of the user guide is governed by these terms. 
The best way to provide notice is to include the following link. 
To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/

-->



<!-- repeater\RefNestedComponents.mxml -->
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
    xmlns:mx="library://ns.adobe.com/flex/mx"
    xmlns:s="library://ns.adobe.com/flex/spark">
    <s:layout>
        <s:VerticalLayout />
    </s:layout>
    <fx:Script>
         
        public function labelTrace():void { 
            for (var i:int = 0; i < nameLabel.length; i++) 
                for (var j:int = 0; j < nameLabel[i].length; j++) 
                    trace(nameLabel[i][j].text); 
        } 
      
    </fx:Script>
    <fx:Declarations>
        <fx:Model id="data">
            <color>
                <colorName>Red</colorName>
                <colorName>Yellow</colorName>
                <colorName>Blue</colorName>
            </color>
        </fx:Model>
        <fx:Model id="catalog">
            <products>
                <product>
                    <name>Name</name>
                    <price>Price</price>
                    <freeship>Free Shipping?</freeship>
                </product>
                <product>
                    <name>Whirlygig</name>
                    <price>5</price>
                    <freeship>false</freeship>
                </product>
                <product>
                    <name>Tilty Thingy</name>
                    <price>15</price>
                    <freeship>true</freeship>
                </product>
                <product>
                    <name>Really Big Blocks</name>
                    <price>25</price>
                    <freeship>true</freeship>
                </product>
            </products>
        </fx:Model>
        <s:ArrayCollection id="myAC1" source="{catalog.product}" />
        <s:ArrayCollection id="myAC2" source="{data.colorName}" />
    </fx:Declarations>
    <s:Label id="title" text="Products:" />
    <mx:VBox>
        <mx:Repeater id="r" dataProvider="{myAC1}" startingIndex="1">
            <mx:Repeater id="r2" dataProvider="{myAC2}">
                <mx:Label id="nameLabel"
                    text="{r2.currentItem} {r.currentItem.name}:${r.currentItem.price}"
                    width="250" />
            </mx:Repeater>
        </mx:Repeater>
    </mx:VBox>
    <s:Button label="Trace" click="labelTrace();" />
</s:Application>

   
    
    
    
    
    
    
    
    
    
    
  








Related examples in the same category

1.Displaying hierarchical XML dataDisplaying hierarchical XML data
2.Declare XML variableDeclare XML variable
3.Using the XML component to embed XML
4.Using the XML class to embed XML
5.Using XML class's static propertiesUsing XML class's static properties
6.Using the source property to filter and bind to XML data
7.Populating XML by binding external dataPopulating XML by binding external data
8.XML used for E4X examples
9.Looping over an XML structure using its indexLooping over an XML structure using its index
10.Looping over an XML fragmentLooping over an XML fragment
11.Adding a child XML node at the endAdding a child XML node at the end
12.For each variable from xml dataFor each variable from xml data
13.Use XMListCollection removeItemAt() method to remove the itemUse XMListCollection removeItemAt() method to remove the item
14.Load Date range data from XMLLoad Date range data from XML
15.Use URLLoader to load XML data from server
16.Construct XML data from returning result from service call
17.Load XML data from server with URLLoader
18.Use reference XML data element and attributeUse reference XML data element and attribute
19.An data model with binding destinations in curly bracesAn <mx:XML> data model with binding destinations in curly braces
20.Define data Model structure with xml
21.Reference attribute value in XML modelReference attribute value in XML model
22.Set the value of the format attribute of the tag to xml
23.Model with a simple XML structure
24.XML data
25.Get value from XML data by using namespaceGet value from XML data by using namespace
26.Get XML from PhpGet XML from Php
27.Navigate an XML Document in E4X
28.Encode an ActionScript Data Object as XML
29.Populate a Component with Complex XML Data
30.Binding XML to ListBinding XML to List
31.Binding XML data to LabelBinding XML data to Label
32.External XML File
33.Bind to Properties on XML by Using E4XBind to Properties on XML by Using E4X
34.Use XPath to get data
35.Use Regular Expressions in E4X Queries
36.Looping over nodes as keysLooping over nodes as keys
37.Inserting a node after an existing one
38.Using || (or) notationUsing || (or) notation
39.Reference Repeated ComponentsReference Repeated Components
40.Referene Repeated Child ComponentsReferene Repeated Child Components
41.Adding and removing leaf nodes at run timeAdding and removing leaf nodes at run time
42.namespace variablenamespace variable