Re: [Flashcoders] how to liesten XML onLoad Event?
here is the infamous scope problem... I use Joey Lott proxy class (http://www.person13.com/articles/proxy/Proxy.htm) to solve that problem when it comes to create an xml parsing class : import ascb.util.Proxy; class MyParser{ private var xml:XML; function MyParser(url:String){ xml = new XML(); xml.ignoreWhite = true; xml.onLoad = Proxy.create(this, this.onXMLLoaded); xml.load(url); } private function onXMLLoaded(success:Boolean):Void { if (success){ var rootNode:XMLNode = xml.firstChild; trace(rootNode.toString()); // now you can do the parsing, call any method of your class here... } else { // ... } } } zikey Han a écrit : The problem is that : In doc.onLoad function assigment , I want to transfer function of showType witch is outside of onLoad assigment! But it can't work! It can't catch Varibles from outside of onLoad. doc.onLoad = function (ok) { trace(type_str+.. ); if (ok) { var str = this.firstChild.childNodes; len = str.length; while (len --) { album_arr.push ({path : str [len].firstChild.nodeValue, url : str [len].attributes.url, name : str [len].firstChild.name}); } showType(); } else { throw new Error (xml document is not found); } } } -- 亲爱的朋友,祝你天天快了! http://www.flashpixy.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] how to liesten XML onLoad Event?
Thanks ,Julien Vignali and j.c.wichman! I can do that ! 亲爱的朋友,祝你天天快了! http://www.flashpixy.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] how to liesten XML onLoad Event?
On 2/21/06, zikey Han [EMAIL PROTECTED] wrote: var doc : XML = new XML (); doc.load (xmlPath); doc.ignoreWhite = true; doc.onLoad = function (ok) {} Put the doc.onLoad function assignment before you call doc.load(xmlPath). E.g. var doc:XML = new XML(); doc.ignoreWhite = true; doc.onLoad = function (ok) { ... } doc.load (xmlPath); Chris -- Chris Velevitch Manager - Sydney Flash Platform Developers Group www.flashdev.org.au ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] how to liesten XML onLoad Event?
On 2/21/06, zikey Han [EMAIL PROTECTED] wrote: Hi,Chris Velevitch, Thank you for your replay!But I use you mathod ,it's helpless! you mean that : put doc.load after doc.onLoad function assigment.But it can do nothing when i compile it! Is the onLoad function being called (put trace statements in it)? Is the XML data there? Is the path to the XML data correct? http://livedocs.macromedia.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Partsfile=2876.html Chris -- Chris Velevitch Manager - Sydney Flash Platform Developers Group www.flashdev.org.au ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] how to liesten XML onLoad Event?
The problem is that : In doc.onLoad function assigment , I want to transfer function of showType witch is outside of onLoad assigment! But it can't work! It can't catch Varibles from outside of onLoad. doc.onLoad = function (ok) { trace(type_str+.. ); if (ok) { var str = this.firstChild.childNodes; len = str.length; while (len --) { album_arr.push ({path : str [len].firstChild.nodeValue, url : str [len].attributes.url, name : str [len].firstChild.name}); } showType(); } else { throw new Error (xml document is not found); } } } -- 亲爱的朋友,祝你天天快了! http://www.flashpixy.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] how to liesten XML onLoad Event?
Hi, It's a scoping issue. Which has been discussed many many times on this list, you might wanna do a search. You can use the delegate class for example to fix this. Greetz Hans -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of zikey Han Sent: Tuesday, February 21, 2006 8:47 AM To: Flashcoders mailing list Subject: Re: [Flashcoders] how to liesten XML onLoad Event? The problem is that : In doc.onLoad function assigment , I want to transfer function of showType witch is outside of onLoad assigment! But it can't work! It can't catch Varibles from outside of onLoad. doc.onLoad = function (ok) { trace(type_str+.. ); if (ok) { var str = this.firstChild.childNodes; len = str.length; while (len --) { album_arr.push ({path : str [len].firstChild.nodeValue, url : str [len].attributes.url, name : str [len].firstChild.name}); } showType(); } else { throw new Error (xml document is not found); } } } -- ?,??! http://www.flashpixy.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com