Flash tutorials | Using XML and E4X,XML data and Parse AS3 in Flash CS3 roundup
AS3 Using XML data and parse it to a List Component - FLASH CS3
Using AS3 to load XML data it’s quite different than using AS2. In this tutorial I will explain to you, how we can load an external XML data, bring it to the fla file, and parse it to a List component. Using your notepad or similar program, make a simple XML file like the above example.
One of the major changes in AS3 is how you deal with XML content. While a lot of similarities carried over from the AS2 days, there are new time-saving niceties in AS3 that make working with XML files easier. One of the introductions is Ecmascript for XML, known as E4X for short. In this tutorial, you will gradually learn more XML tricks as you try to parse the various parts of the following XML data:
Flash CS3 Export Motion XML
Flex has had effects since its initial release. The limitation of these effects is largely that they are all fundamentally linear in nature. You can move something in a straight line from Point A to Point B for example. You can fade a display object in and out, but again only as one continuously incremented/decremented animation. What if you wanted to move something along a curved path? What if you wanted to fade in and out at various levels along the path of that curve? Until Flash CS3, this is something that would have been particularly challenging, but we now have “Export Motion XML”.
E4X uses the new top-level XML and XMLList classes. The simplest and most common way to declare a variable of one of these types is to pass String data formatted as XML to the constructor. However, many developers might miss the fact that one can declare XML directly within your classes or ActionScript code–not as a String, but natively. The compiler can understand it perfectly.
Actionscript 3.0 finally introduced the powerful XML handling E4X ECMAScript for XML.
This new class introduces a new way to look at the XML strings using native actionscript objects.
You can read the full specifications of this powerful sub-language at http://www.ecma-international.org/../Ecma-357.htm
Flash ActionScript 3.0 XML Text Array Loader
After creating the Flash 8 ActionScript 2.0 Image slideshow modifications, I wanted to start from scratch on my next set of tutorials with AS3. AS3 is very different from AS2, the learning curve is not easy but its worth it. I would like to recommend a few books to help you get started in AS3; Essential ActionScript 3.0 by Colin Moock and Learning ActionScript 3.0: A Beginners Guide by Rich Shupe and Zevan Rosser. This is my first tutorial in a series where I will be rebuilding the XML/Flash Slideshow in ActionScript 3.0.In this tutorial, I will be focusing on how to setup your XML file, how to read in text from that XML file into you flash, and how to move through the xml nodes in your flash file and have them show up.First thing is first, how do you setup your XML file, I used a lot of examples from Colin Moock’s book to achieve this. By no way is my way the right way, since XML is pretty flexible. I setup my xml file by opening up with a parent node “images” then placing all of the attributes within each node “image”. AS3 makes it really easy to pull the varibles out, so thats why I set it up this way
I’ve been using E4X in ActionScript 3.0 for a while now and the rumors of its simplicity have been greatly exaggerated. A lot of operations are easy and make sense, but others are less… obvious. E4X is essentially a whole new language which is part of the AS3 grammar, just as regular expressions have their own completely different language but exist within ActionScript 3.0. And being so new, there really isn’t a whole lot of documentation out there. This is further complicated by the fact that since E4X seems simple enough at first glance to explain in a few lines, a lot of documentation stops short.
Anyway. I’ve been infuriated by E4X more than a few times now, and I’d like to start a running post to demystify some of it. Please! use the comments to ask any questions you might have, and I’ll keep adding to this post. Hopefully this can turn into a decent resource for E4X lore. The fun begins after the cut.
Defining Dynamic XML Literals in ActionScript 3
Recently, I was working on my first Flex project where I was consuming XML via a service. Whenever I wanted to make data changes with the service, I was required to send in an XML packet. Since AS3 has native support for XML literals, I wanted to create my small XML packet inline. For example:
Loading XML data using ActionScript 3.0
Using XML is one of the best ways for structuring external content in a logical format that is easy to understand, process, and update. This tutorial will teach you the basics on how to load and process XML in Flash using ActionScript 3.0. You are assumed to have basic knowledge of ActionScript in order to follow this tutorial.
Loading XML data in Flash using ActionScript
XML can be used to load external data in Flash to provide an easy method for structuring content so that it is easy to understand, process, and update. This tutorial will teach you the basics on how to create a Flash-friendly XML file and how to load and process this XML file in Flash using the ActionScript XML object. You are assumed to have intermediate knowledge of ActionScript in order to follow this tutorial.
Using XML Namespaces with E4X and ActionScript 3
Here is a simple example demonstrating how to use namespaces to access element nodes using E4X syntax. Create a new Flex Project and paste the code in the main .mxml file:
Flex 2, Actionscript 3, and E4X
I’ve found a feature of Actionscript 3 (AS3) that I’ve not seen in other languages that I think is pretty cool. It’s taken me awhile to come to terms with it, but now that I’ve getting more comfortable with it I’m really starting to appreciate it. That feature is what is known as E4X or more officially Standard ECMA-357 ECMAScript for XML (E4X) Specification. At its core is the ability to work with and manipulate XML data in AS3 using standard language syntax instead of having to do everything through an API.
Sort XML by Attribute in Actionscript 3
I love working with E4X, but I wish there was an easy way to sort an XML based on an attribute.
After looking around I couldn’t really find a good solution or maybe people weren’t explaining themselves correctly, or I wasn’t googling correctly. So I decided just to write my own small utility class.
When I thought about it. Arrays provide a superb sortOn() function, and it’s relatively easy to leverage that.
Video:
Tutorial: Xml & Actionscript 3.0
This tutorial shows how to use the new XML features in AS3 by creating a simple RSS reader.
Adobe:














Comments (0)
Trackbacks - Pingbacks (2)
August 20th, 2008 at 10:17
[...] [...]
October 20th, 2008 at 19:35
[...] public links >> ecma Flash tutorials | Using XML and E4X,XML data and Parse AS3 in … First saved by qmosaic | 1 days ago What is the future of ActionScript? First saved by [...]
Leave a Reply