Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > General > Best Practices

Reply
 
Thread Tools Rating: Thread Rating: 1 votes, 3.00 average. Display Modes
Old 03-15-2011, 04:26 PM   #11
drkstr
Flexpert
 
drkstr's Avatar
 
Join Date: Sep 2006
Location: Seattle, WA: USA
Posts: 1,587
Default

Quote:
Originally Posted by senocular View Post
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.
^^^ What he said.

My 2 cents...

Our applications are usually very data driven in nature, and often require a significant amount of data modeling before development even begins. As a result, it makes more sense for us to use strongly typed model classes that proxy their data source (xml, web service, etc.). This way we can program against the model, and not have to worry about the specific data implementation, not to mention a bit of optimization at compile time. We also use a modeling program to export model code into various languages (Enterprise Architect and it works great with AS3).

Programming business logic against native XML objects would not be ideal in our situation, and I would argue against it in any "enterprise-level" application, but that is only an opinion.

Last edited by drkstr; 03-15-2011 at 04:36 PM.
drkstr is offline   Reply With Quote
Old 06-12-2011, 04:41 PM   #12
4leggedcreature
Registered User
 
Join Date: Sep 2005
Location: The Netherlands
Posts: 15
Default

Hi manco, I used to always convert the XML data into (multi) array's. For everything I want I had an array, for example title, description, url, etc. It was a painstaken process.
Now with XML (E4X style) in AS3 it is way way more easier. Now I just make the XML I want and use for each to loop through anything I want. No more converting to arrays.
4leggedcreature is offline   Reply With Quote
Old 03-29-2012, 01:58 PM   #13
Rayb
Registered User
 
Join Date: Feb 2012
Posts: 1
Default

I know it's an old thread, but I wanted to point out WHY anyone would think of converting XML to Arrays: Speed! In AS2 if you tried to parse a very long XML file, it could be so slow that the Flash player would think it was caught in an infinite loop and would show the "a script is taking a long time to execute. Stop scripts?" prompt.

This might still be relevant in AS3 if an xml file is long enough.

Rayb is offline   Reply With Quote
Old 03-29-2012, 04:10 PM   #14
drkstr
Flexpert
 
drkstr's Avatar
 
Join Date: Sep 2006
Location: Seattle, WA: USA
Posts: 1,587
Default

Quote:
Originally Posted by Rayb View Post
This might still be relevant in AS3 if an xml file is long enough.
I would say it's even more relevant in AS3, due to all the optimization gained in static typing.

Preforming operations on an XML structure is incredibly slow, when compared to preforming those same operations on a static type (or even an array of dynamic objects).
drkstr is offline   Reply With Quote
Old 03-31-2012, 10:00 AM   #15
wvxvw
Holosuit User
 
wvxvw's Avatar
 
Join Date: Oct 2006
Location: Tel Aviv
Posts: 4,301
Send a message via ICQ to wvxvw
Default

There is absolutely no difference between using Array and XMLNode.children because the later is an array. So, by moving the children of an XMLNode from one array to another you gain absolutely nothing. This is identical in AS2 and AS3 bar that AS3 offers static typing, so field resolution for the field 'children' is now faster, then it was in AS2, but the access to children is probably the same, because it is dynamic.
__________________
The .NET open source editor for Flash and web developers
*This would be my contribution to the project*
couchsurfing if you need it

Last edited by wvxvw; 03-31-2012 at 10:09 AM.
wvxvw is offline   Reply With Quote
Old 04-04-2012, 03:45 AM   #16
peptobismol
Senior Member
 
Join Date: Oct 2005
Posts: 746
Default

You probably don't want to propagate an array from an XML in a mobile platform. It'll take up 2x the memory space and will crash if long enough.
peptobismol is offline   Reply With Quote
Old 04-25-2012, 12:03 AM   #17
drkstr
Flexpert
 
drkstr's Avatar
 
Join Date: Sep 2006
Location: Seattle, WA: USA
Posts: 1,587
Default

Quote:
Originally Posted by peptobismol View Post
You probably don't want to propagate an array from an XML in a mobile platform. It'll take up 2x the memory space and will crash if long enough.
Yeah, we ended up just ditching XML all together on the mobile. Binary AMF works much better on this platform.

I would agree that in most cases, you would end up on the losing end in a conversion from XML to another format. Most of the resources used with XML is an upfront cost, which will need to be paid one way or the other. However, once this toll has been paid, I would think operating on binary is more efficient than operating on a dynamic XML structure, considering even something as slight as using object literal notation is faster than calling new Object() (irrelevant, but my point is that dynamic == overhead).

This has me curious now. I'll have to play around with a few different tests and determine which (if any) situations would actually call for a conversion.

*PS*

Sorry for my technically incorrect use of "binary" in that second paragraph, I wasn't sure what else to call it. I realize an XML node is also binary, once parsed from a string... it just has a lot of cruft on top of it, which is what I was trying to get at.

Last edited by drkstr; 04-25-2012 at 04:11 AM. Reason: Added a foot note
drkstr is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Tracing array from a xml doesn`t work ferrarih ActionScript 2.0 1 11-03-2007 08:16 PM
XML to ARRAY problem and more vascq ActionScript 1.0 (and below) 1 06-06-2007 11:58 AM
Problem with a for...in loop in a for...in loop VictoriaWelby ActionScript 2.0 2 04-09-2007 11:20 PM
AS3 Loaded XML into DataGrid chuckgrenade Flex 2, 3 & 4 11 03-27-2007 07:55 PM
releasing xml file from XML.onLoad() sophistikat ActionScript 2.0 2 02-21-2007 07:00 PM


All times are GMT. The time now is 07:58 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.