OZONE Asylum
Forums
Multimedia/Animation
Flash, XML, class constructors
This page's ID:
11461
Search
QuickChanges
Forums
FAQ
Archives
Register
Edit Post
Who can edit a post?
The poster and administrators may edit a post. The poster can only edit it for a short while after the initial post.
Your User Name:
Your Password:
Login Options:
Remember Me On This Computer
Your Text:
Insert Slimies »
Insert UBB Code »
Close
Last Tag
|
All Tags
UBB Help
I'm just now learning Flash, and I'm having a problem that might have an obvious solution. I'm creating a class which gets an XML file from my PHP backend, keeps it as a Flash XML object, and doles out relevant information when requested. It looks like this: [code] class GameData { [i]// instance variables[/i] private var game_xml; [i]// constructor[/i] function GameData(url) { game_xml = new XML(); game_xml.ignoreWhite = true; game_xml.onLoad = gameOnLoad; game_xml.load(url); trace("Loading XML file."); } function gameOnLoad(success) [i]// variable [b]success[/b] is sent by event[/i] { if (success) trace("XML file contents: " + game_xml.toString()); } [i]// rest of class, mostly getThing() functions that request specific nodes[/i] } [/code] According to every Flash/XML tutorial and document I can find, this should work. The XML.load() function should put the contents of the URL variable into the XML object (game_xml in this case), and then game_xml.toString() should return a text representation of the XML doc. This does not happen for me. Instead, I have to do this (only relevant parts shown): [code] [i]// this is in the constructor[/i] game_xml.onLoad = function(success) { if (success) { game_xml = this; } } game_xml.load(url); [/code] And then everything works great. The trouble is, I haven't seen that thing about setting game_xml equal to itself (since, if I'm right, [b]this[/b] called from [b]game_xml.onLoad()[/b] is in fact game_xml)... So what am I doing wrong? Or if I'm not doing something wrong, where's the hole in my understanding? I'm going to proceed empirically, but I'd like to know the theory. [url=http://faq.ozoneasylum.com/1250]Cell 1250[/url] :: [url=http://www.alanmacdougall.com]alanmacdougall.com[/url] :: [url=http://www.gurusnetwork.com/tutorials/illustrator/index.html]Illustrator tips[/url]
Loading...
Options:
Enable Slimies
Enable Linkwords
« Backwards
—
Onwards »