The following example shows how you can use an XML document as a data provider for a Spark List control in Flex 4 by using an XMLListCollection.
Full code after the jump.
The following example(s) require Flash Player 10 and the Adobe Flex 4 SDK. To download the Adobe Flash Builder 4 trial, seehttp://www.adobe.com/products/flex/. To download the latest nightly build of the Flex 4 SDK, seehttp://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+4.
For more information on getting started with Flex 4 and Flash Builder 4, see the official Adobe Flex Team blog.
<?xml version="1.0"?> <!-- http://blog.flexexamples.com/2009/11/04/using-an-xml-data-provider-with-the-spark-list-control-in-flex-4/ --> <s:Application name="Spark_List_dataProvider_XML_test" xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/halo"> <s:List id="lst" labelField="@label" horizontalCenter="0" verticalCenter="0"> <s:dataProvider> <s:XMLListCollection> <fx:XMLList xmlns=""> <node label="One" /> <node label="Two" /> <node label="Three" /> <node label="Four" /> <node label="Five" /> <node label="Six" /> <node label="Seven" /> <node label="Eight" /> <node label="Nine" /> </fx:XMLList> </s:XMLListCollection> </s:dataProvider> </s:List> </s:Application>
Or, if you wanted to embed the XML into your application, you could use the <fx:XML/> tag and bind to an XMLListCollection, as seen in the following example:
<?xml version="1.0"?> <!-- http://blog.flexexamples.com/2009/11/04/using-an-xml-data-provider-with-the-spark-list-control-in-flex-4/ --> <s:Application name="Spark_List_dataProvider_XML_test" xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/halo"> <fx:Declarations> <fx:XML id="nodes" source="nodesAndStuff.xml" /> </fx:Declarations> <s:List id="lst" labelField="@label" horizontalCenter="0" verticalCenter="0"> <s:dataProvider> <s:XMLListCollection source="{nodes.children()}" /> </s:dataProvider> </s:List> </s:Application>
And the external .XML file, nodesAndStuff.xml, is as follows:
<?xml version="1.0" encoding="utf-8"?> <!-- http://blog.flexexamples.com/2009/11/04/using-an-xml-data-provider-with-the-spark-list-control-in-flex-4/ --> <root> <node label="One" /> <node label="Two" /> <node label="Three" /> <node label="Four" /> <node label="Five" /> <node label="Six" /> <node label="Seven" /> <node label="Eight" /> <node label="Nine" /> </root>
Or, if you didn’t want to use data binding, Corey, you could set the data provider using ActionScript, as seen in the following example:
<?xml version="1.0"?> <!-- http://blog.flexexamples.com/2009/11/04/using-an-xml-data-provider-with-the-spark-list-control-in-flex-4/ --> <s:Application name="Spark_List_dataProvider_XML_test" xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/halo" initialize="init();"> <fx:Script> <![CDATA[ private function init():void { xmlListColl.source = nodes.children(); } ]]> </fx:Script> <fx:Declarations> <fx:XML id="nodes" source="nodesAndStuff.xml" /> </fx:Declarations> <s:List id="lst" labelField="@label" horizontalCenter="0" verticalCenter="0"> <s:dataProvider> <s:XMLListCollection id="xmlListColl" /> </s:dataProvider> </s:List> </s:Application>
This entry is based on a beta version of the Flex 4 SDK and therefore is very likely to change as development of the Flex SDK continues. The API can (and will) change causing examples to possibly not compile in newer versions of the Flex 4 SDK.
分享到:
相关推荐
• Understand Spark’s evolving role in the Big Data and Hadoop ecosystems • Create Spark clusters using various deployment modes • Control and optimize the operation of Spark clusters and ...
It also addresses advanced topics in Spark, starting with the basics of Scala and the core Spark framework, and exploring Spark data frames, machine learning using Mllib, graph analytics using Graph ...
Apache Spark has emerged as the next big thing in the Big Data domain – quickly rising from an ascending technology to an established superstar in just a matter of years. Spark allows you to quickly ...
It also addresses advanced topics in Spark, starting with the basics of Scala and the core Spark framework, and exploring Spark data frames, machine learning using Mllib, graph analytics using Graph ...
"Data Analytics with Hadoop: An Introduction for Data Scientists" ISBN: 1491913703 | 2016 | PDF | 288 pages | 7 MB Ready to use statistical and machine-learning techniques across large data sets? ...
With its ease of development (in comparison to the relative complexity of Hadoop), it’s unsurprising that it’s becoming popular with data analysts and engineers everywhere. Beginning with the ...
ActionScript 3.0 introduces some fundamental changes to the way in which Flash and Flex applications work with XML. One significant change is that XML is now a native data type. ActionScript 3.0 also ...
Apache Spark has emerged as the next big thing in the Big Data domain – quickly rising from an ascending technology to an established superstar in just a matter of years. Spark allows you to quickly ...
You can learn about Apache Spark and develop Spark programs for various use cases in big data analytics using the code examples provided. This book covers all the libraries in Spark ecosystem: Spark ...
Find out and implement the tools and techniques of big data analytics using Spark on Hadoop clusters with wide variety of tools used with Spark and Hadoop Understand all the Hadoop and Spark ecosystem...
Written by an expert team well-known in the big data community, this book walks you through the challenges in moving from proof-of-concept or demo Spark applications to live Spark in production....
This is an advanced guide for those with beginner-level familiarity with the Spark architecture and working with Data Science applications. Mastering Spark for Data Science is a practical tutorial ...
本书描述了如何使用Spark架构进行大数据分析,包含了大规模数据处理、机器学习、图分析、高速数据流处理。
Next-Gen Big Data Analytics using the Spark stack.zip
Bug with the AV failure when using the BLOB data type in Lazarus is fixed SQLite data provider Now the Direct mode is based on the SQLite engine version 3.26.0 DBF data provider Bug with wrong ...
Everything you need to know about using the standard list control in your applications
An introduction to SparkR is covered next.Later, we cover the charting and plotting features of Python in conjunction with Spark data processing. After that, we take a look at Spark’s stream ...
Spark in Action teaches you the theory and skills you need to effectively handle batch and streaming data using Spark. You'll get comfortable with the Spark CLI as you work through a few introductory ...
This means that the content in the chapters is focused on developing solutions to simplified, but still realistic problems using data-intensive technologies and approaches. The reader follows one ...
Extend your data processing capabilities to process huge chunk of data in minimum time using advanced concepts in Spark. Master the art of real-time processing with the help of Apache Spark 2.x Who ...