PDA

View Full Version : in AS3 is it necessary to put XML into array anymore?


manco
12-19-2007, 04:32 AM
Since XML is now an Object is it still recommended to transfer over the data into an array like you would in AS2? Doesn't seem that necessary to me anymore but wanted some opinions.

Thanks

newblack
12-19-2007, 03:55 PM
when would you want to convert XML to Arrays? never heard of that before. it's a natively supported Object, there's no need to do any conversion.

manco
12-19-2007, 04:12 PM
Sorry my wording was wrong. I meant store XML objects in Arrays. In AS2 I use to load in XML, convert them to objects with each nodes properties, and store them in arrays for reference later on. I don't see the point of doing that anymore in AS3 but was looking for some opinions for or against that. Hopefully that clarifies my post.

scootersim
12-24-2007, 06:43 PM
Even in AS2 I don't think you were REQUIRED to write to an Array object. It certainly was an option, but not a mandate. Some used to think it was easier to work with arrays than it was with the XML object, but I don't see it.

Short answer is: No.

Flash Gordon
01-05-2008, 05:21 PM
Hi Manco,

I used to do the same thing. It would much easier to do eventDates[5] than to do xml.firstChild.firstChild.firstChild.nextSibling.f irstChild.nodeValue.

However, XML/E4X in AS 3.0 is so easy to access, that kind of logic isn't needed. Read here: http://www.senocular.com/flash/tutorials/as3withflashcs3/?page=4#e4x

peptobismol
01-07-2008, 02:25 AM
wow.. e4x does make the process easier. i'd have to switch to as3.0 one day.

mux
02-19-2008, 12:14 PM
hi guys..
i had the same thinking regards arrays like the question
so before we looped the contents of an xml to store the contains to objects vars array etc.

now we can just call them by name once that XML var has the complete xml in it.

am i correct?

ps. this senocular tutorial is just great. god bless him

ActionScription
08-06-2008, 06:12 AM
I'm researching the same thing. I've found several speed trials that compare the speed of looping an array, object, and dictionary. But haven't seen how looping through in xml compares. Anyone know if speed is an issue? And at what point is it worth converting data from a slower form to a faster one? B/c, although it is fully supported in AS3, xml may still be slower.

BTW: arrays are quickest, followed by dictionaries, and finally objects: Check out pixelwork's comparison test (http://pixelwelders.com/blog/best-practices/2008/speed-tests-objects-vs-arrays-vs-dictionaries/)

( http://pixelwelders.com/blog/best-practices/2008/speed-tests-objects-vs-arrays-vs-dictionaries/ )

senocular
08-06-2008, 12:04 PM
In general, E4X is a little slower than other objects. There's an obvious overhead to sorting through an xml's hierarchy using the E4X syntax. However, when considering the extraction of data from an unknown XML structure where you're targeting a collection of nodes of a certain name, E4X is actually faster that using other techniques to traverse the tree manually. So in the end it's circumstantial.