Building Flash-based websites using Adobe Flex - Lesson 8/10
-
Upload
stefano-virgilli -
Category
Education
-
view
661 -
download
3
description
Transcript of Building Flash-based websites using Adobe Flex - Lesson 8/10
![Page 2: Building Flash-based websites using Adobe Flex - Lesson 8/10](https://reader035.fdocuments.in/reader035/viewer/2022080210/5564d93ad8b42a0a178b55c1/html5/thumbnails/2.jpg)
Agenda
● Introduction to XML
● Managing special characters in XML
● XML in Flex
● Extracting XML in Flex
● JSON
![Page 3: Building Flash-based websites using Adobe Flex - Lesson 8/10](https://reader035.fdocuments.in/reader035/viewer/2022080210/5564d93ad8b42a0a178b55c1/html5/thumbnails/3.jpg)
● Extensible Markup Language (XML) is a type of markup language for structuring data hierarchically.
● XML is tag-based, like HTML/MXML, but is designed for representing information rather than controlling visual display.
● Most commonly used to represent data passed from a remote server.
Introduction to XML
![Page 4: Building Flash-based websites using Adobe Flex - Lesson 8/10](https://reader035.fdocuments.in/reader035/viewer/2022080210/5564d93ad8b42a0a178b55c1/html5/thumbnails/4.jpg)
● ECMAScript for XML (E4X) is the latest standard for reading and writing XML documents.
● One of the most significant changes to ActionScript 3.0 is its native support for E4X. This allowsdevelopers to work seamlessly with XML in their programs without additional parsing.
Introduction to XML
![Page 5: Building Flash-based websites using Adobe Flex - Lesson 8/10](https://reader035.fdocuments.in/reader035/viewer/2022080210/5564d93ad8b42a0a178b55c1/html5/thumbnails/5.jpg)
● Certain characters are reserved for an internal use in XML documents. These include the less than (<) and greater than (>) signs, which mark the beginning and end of tag names.
● If we need to include reserved characters in text within an XML node, we can either use:
● a CDATA declaration; or● escape codes to represent the character.
● A sample list of reserved characters and their corresponding escape codes
Managing Special Characters in XML
![Page 6: Building Flash-based websites using Adobe Flex - Lesson 8/10](https://reader035.fdocuments.in/reader035/viewer/2022080210/5564d93ad8b42a0a178b55c1/html5/thumbnails/6.jpg)
e.g.
Managing Special Characters in XML
![Page 7: Building Flash-based websites using Adobe Flex - Lesson 8/10](https://reader035.fdocuments.in/reader035/viewer/2022080210/5564d93ad8b42a0a178b55c1/html5/thumbnails/7.jpg)
● Following are the relevant XML classes:
● XML – an XML object with a valid xml string● XMLList – an array of XML objects● XMLListCollection – an “ArrayCollection” of XML objects
● e.g.
XML in Flex
![Page 8: Building Flash-based websites using Adobe Flex - Lesson 8/10](https://reader035.fdocuments.in/reader035/viewer/2022080210/5564d93ad8b42a0a178b55c1/html5/thumbnails/8.jpg)
e.g.
Alert.show( sales.item[0].type ); //apples
Alert.show( sales.item[2].price ); //5.16
Extracting Data from XML
![Page 9: Building Flash-based websites using Adobe Flex - Lesson 8/10](https://reader035.fdocuments.in/reader035/viewer/2022080210/5564d93ad8b42a0a178b55c1/html5/thumbnails/9.jpg)
● JavaScript Object Notation (JSON) is another data format that is widely used for representing data from the server.
● Originally made for JavaScript and AJAX.
● JSON is not natively supported in Flex, requires a plug-in library from Adobe - http://labs.adobe.com/wiki/index.php/ActionScript_3:resources:apis:libraries#corelib
e.g.
JSON