Re: [Flashcoders] XML loading and parsing problem
It's completely wrong to insist that you have to use a delegate in all situations. Delegate is teh bomb dot com. If u don't use it, ur n00b. ;) ___ 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] XML loading and parsing problem
haha i use it :D but never when loading xml... On 7/10/07, Steven Sacks [EMAIL PROTECTED] wrote: It's completely wrong to insist that you have to use a delegate in all situations. Delegate is teh bomb dot com. If u don't use it, ur n00b. ;) ___ 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 -- Omar M. Fouad - Digital Emotions http://www.omarfouad.net +2010 - 2346633 - +2012 - 261 ___ 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] XML loading and parsing problem
Delegate is teh bomb dot com. If u don't use it, ur n00b. Or you're using the current version of Actionscript, AS3. :) Jason Merrill Bank of America GTO Learning Leadership Development eTools Multimedia Team ___ 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] XML loading and parsing problem
hey thanks folks!!! On 7/9/07, Muzak [EMAIL PROTECTED] wrote: Damn, my secret's out :( - Original Message - From: Jesse Graupmann [EMAIL PROTECTED] To: flashcoders@chattyfig.figleaf.com Sent: Monday, July 09, 2007 1:36 AM Subject: RE: [Flashcoders] XML loading and parsing problem Muzak, we all know you bought stock in Delegate back in the day - you're just protecting your assets. I'm still curious what the Delegate tattoo looks like... ;) ___ 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 -- Omar M. Fouad - Digital Emotions http://www.omarfouad.net +2010 - 2346633 - +2012 - 261 ___ 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] XML loading and parsing problem
- Original Message - From: Omar Fouad [EMAIL PROTECTED] To: flashcoders@chattyfig.figleaf.com Sent: Sunday, July 08, 2007 1:07 AM Subject: Re: [Flashcoders] XML loading and parsing problem YESS! thanks DUDE actually it worked without delegate, when i added ignore white...:D You only need to use a delegate when 'this' is different inside the onLoad function and where it's set up. If the xml is all setup on the main timeline, then 'this' is the same in both cases and the use of Delegate is not required, however if you set up the loading inside a class, you must use a delegate so that the class context will be accessible from within the onLoad function. Paul. ___ 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] XML loading and parsing problem
- Original Message - From: Muzak [EMAIL PROTECTED] To: flashcoders@chattyfig.figleaf.com Sent: Sunday, July 08, 2007 1:55 AM Subject: Re: [Flashcoders] XML loading and parsing problem 3 people posting similar (allmost identical) examples, all using Delegate should give you a clue ;-) Well, it may be a misleading clue since it's not strictly necessary if the code is on the main timeline.. It's completely wrong to insist that you have to use a delegate in all situations. Paul - Original Message - From: Omar Fouad [EMAIL PROTECTED] To: flashcoders@chattyfig.figleaf.com Sent: Sunday, July 08, 2007 2:07 AM Subject: Re: [Flashcoders] XML loading and parsing problem YESS! thanks DUDE actually it worked without delegate, when i added ignore white...:D ___ 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] XML loading and parsing problem
erhmm.. Then show me how you use 'this' inside an xml onload handler to invoke a method outside the handler. Or better yet, prove me this: quote If the xml is all setup on the main timeline, then 'this' is the same in both cases /quote regards, Muzak - Original Message - From: Paul Andrews [EMAIL PROTECTED] To: flashcoders@chattyfig.figleaf.com Sent: Sunday, July 08, 2007 5:10 PM Subject: Re: [Flashcoders] XML loading and parsing problem - Original Message - From: Muzak [EMAIL PROTECTED] To: flashcoders@chattyfig.figleaf.com Sent: Sunday, July 08, 2007 1:55 AM Subject: Re: [Flashcoders] XML loading and parsing problem 3 people posting similar (allmost identical) examples, all using Delegate should give you a clue ;-) Well, it may be a misleading clue since it's not strictly necessary if the code is on the main timeline.. It's completely wrong to insist that you have to use a delegate in all situations. Paul ___ 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] XML loading and parsing problem
On 7/8/07, Paul Andrews [EMAIL PROTECTED] wrote: It's completely wrong to insist that you have to use a delegate in all situations. True--another case where you don't need them is when using static functions. -- Mike Keesey ___ 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] XML loading and parsing problem
OK, my comment about 'this' isn't completely right, but I am certainly right about the use of Delegate for the XML loader. You comment about 'this' was completely wrong.. ;-) You're right if you say that *you don't have to* use Delegate to be able to access variables outside an onLoad hander, but the fact remains that the scope has changed, and that's the important part. When you do this: var foo = bar; test.onLoad = function(success) { trace(foo); } you're relying on Flash to look up the variable (which it will) and that's why it works. Things also get more complicated/missleading when you do something like this: var foo = bar; function loadHandler() { trace(foo); } test = new XML() // etc.. test.onLoad = loadHandler; Seeing it like that (nice and together) one could note that the loadHandler function runs in a different scope than the one it resides in (the timeline). But what if the loadHandler function and the onLoad assignment are separated by 100 lines of code? Then things aren't that obvious anymore and leads to missleading code. Using Delegate is just one of those best practices and should be used at all times, even if it kinda works without. regards, Muzak - Original Message - From: Paul Andrews [EMAIL PROTECTED] To: flashcoders@chattyfig.figleaf.com Sent: Sunday, July 08, 2007 6:32 PM Subject: Re: [Flashcoders] XML loading and parsing problem OK, my comment about 'this' isn't completely right, but I am certainly right about the use of Delegate for the XML loader. If you don't use the Delegate class and try and access the attributes of a class within an onLoad function, you won't have access to the class atrributes, so you must use a delegate. If you don't use the Delegate class on the main timeline and try and access the variables declared on the timeline you will be able to access them, so you don't have to use a delegate. Stick the following code onto the timeline and see how you get on.. Paul stop(); var thisVariable:String=This is me; trace(this.thisVariable); var test:XML = new XML(); test.ignoreWhite = true; test.onLoad = function(success) { if (success) { trace(loaded); trace(thisVariable); trace(this.thisVariable); } }; test.load(test.xml); /* test.xml: test something / /test */ ___ 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] XML loading and parsing problem
I never said you have to use a delegate in all situations. - Original Message - From: T. Michael Keesey [EMAIL PROTECTED] To: flashcoders@chattyfig.figleaf.com Sent: Sunday, July 08, 2007 6:16 PM Subject: Re: [Flashcoders] XML loading and parsing problem On 7/8/07, Paul Andrews [EMAIL PROTECTED] wrote: It's completely wrong to insist that you have to use a delegate in all situations. True--another case where you don't need them is when using static functions. -- Mike Keesey ___ 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] XML loading and parsing problem
Using Delegate is just one of those best practices and should be used at all times, even if it kinda works without. +1 Also, Omar *might* want to refactor his code later. Using Delegate he likely won't run into any trouble. Cheers, Claus. ___ 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] XML loading and parsing problem
- Original Message - From: Muzak [EMAIL PROTECTED] To: flashcoders@chattyfig.figleaf.com Sent: Sunday, July 08, 2007 6:22 PM Subject: Re: [Flashcoders] XML loading and parsing problem OK, my comment about 'this' isn't completely right, but I am certainly right about the use of Delegate for the XML loader. You comment about 'this' was completely wrong.. ;-) Well for lesser beings (from the flash help): this property this References an object or movie clip instance. When a script executes, this references the movie clip instance that contains the script. When a method is called, this contains a reference to the object that contains the called method. Inside an on() event handler attached to a button, this refers to the Timeline that contains the button. Inside an onClipEvent() event handler attached to a movie clip, this refers to the Timeline of the movie clip itself. Because this is evaluated in the context of the script that contains it, you can't use this in a script to refer to a variable defined in a class file. You're right if you say that *you don't have to* use Delegate to be able to access variables outside an onLoad hander, but the fact remains that the scope has changed, and that's the important part. Well, nobody ever mentioned that - Delegate was proposed as apparently the only way forward. When you do this: var foo = bar; test.onLoad = function(success) { trace(foo); } you're relying on Flash to look up the variable (which it will) and that's why it works. Well that's why *anything* works. Things also get more complicated/missleading when you do something like this: var foo = bar; function loadHandler() { trace(foo); } test = new XML() // etc.. test.onLoad = loadHandler; Seeing it like that (nice and together) one could note that the loadHandler function runs in a different scope than the one it resides in (the timeline). But what if the loadHandler function and the onLoad assignment are separated by 100 lines of code? Then things aren't that obvious anymore and leads to missleading code. I don't see what this has to do with delegate. I can use Delegate and still have 100 lines of code between it and the function. Using Delegate is just one of those best practices and should be used at all times, even if it kinda works without. Well, best practice wasn't mentioned until now. I think kinda works is actually does work. The OP was reporting a problem and many people seemed to suggest that Delegate was going to help solve the problem, something that was entirely erroneous. Best practice, fine. Only practice, no. regards, Muzak Paul ___ 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] XML loading and parsing problem
Look Ma! No Delegate /// var scope = this; var callback = xml_parse; xmlData = new XML(); xmlData.ignoreWhite = true; xmlData.onLoad = xml_loaded; xmlData.load ( gallery.xml ); function xml_loaded( success:Boolean ) { if ( success ) scope [ callback ] ( this ); } function xml_parse ( xml:XML ) { var total = xml.firstChild.firstChild.childNodes.length; trace ( this + xml_loaded :: total: + total ); } /// xmlData = new XML(); xmlData.scope = this; xmlData.ignoreWhite = true; xmlData.onLoad = function ( success:Boolean ) { if ( success ) this.scope.xml_parse ( this ); } xmlData.load ( gallery.xml ); function xml_parse ( xml:XML ) { var total = xmlData.firstChild.firstChild.childNodes.length; trace ( this + xml_loaded :: total: + total ); } /// Event Dispatcher /// xmlData = new XML(); xmlData.ignoreWhite = true; xmlData.onLoad = function ( success:Boolean ) { this.dispatchEvent ( { target:this, type:xml_onLoad, success:success } ) } mx.events.EventDispatcher.initialize ( xmlData ); xmlData.addEventListener ( xml_onLoad, this ); xmlData.load ( gallery.xml ); function xml_onLoad ( evt:Object ) { var xml = evt.target; var total = xmlData.firstChild.firstChild.childNodes.length; trace ( this + xml_loaded :: total: + total ); } /// Or, sorta Delegate style... /// function createAndLoadXML ( path:String, scope:Object, callback:Function ) { var func = function ( success:Boolean ) { this.onLoad = null; // clear some memory? var scope = arguments.callee.scope; var callback = arguments.callee.callback; callback.call ( scope, this, success ); } func.scope = scope; func.callback = callback; func.xml = new XML(); func.xml.ignoreWhite = true; func.xml.onLoad = func; func.xml.load ( path ); } function xml_parse ( xml:XML, success:Boolean ) { var total = xml.firstChild.firstChild.childNodes.length; trace ( this + xml_loaded :: total: + total ); } createAndLoadXML ( gallery.xml, this, xml_parse ); _ Jesse Graupmann www.jessegraupmann.com www.justgooddesign.com/blog/ _ -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Paul Andrews Sent: Sunday, July 08, 2007 12:22 PM To: flashcoders@chattyfig.figleaf.com Subject: Re: [Flashcoders] XML loading and parsing problem Best practice, fine. Only practice, no. regards, Muzak Paul ___ 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] XML loading and parsing problem
Muzak, we all know you bought stock in Delegate back in the day - you're just protecting your assets. I'm still curious what the Delegate tattoo looks like... ;) -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Muzak Sent: Sunday, July 08, 2007 3:57 PM To: flashcoders@chattyfig.figleaf.com Subject: Re: [Flashcoders] XML loading and parsing problem The OP was reporting a problem and many people seemed to suggest that Delegate was going to help solve the problem, something that was entirely erroneous. I mentioned Delegate in response to this piece of code (posted by Fruber): gallery.onLoad = function( bSuccess ) { if ( bSuccess ) fun( this ); }; fun( xmlInfo:XML ):Void { // perform your XML stuff. } And then Omar asked: quoteMuzak... why Delegate??/quote regards, Muzak ___ 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] XML loading and parsing problem
Damn, my secret's out :( - Original Message - From: Jesse Graupmann [EMAIL PROTECTED] To: flashcoders@chattyfig.figleaf.com Sent: Monday, July 09, 2007 1:36 AM Subject: RE: [Flashcoders] XML loading and parsing problem Muzak, we all know you bought stock in Delegate back in the day - you're just protecting your assets. I'm still curious what the Delegate tattoo looks like... ;) ___ 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] XML loading and parsing problem
coughmx.utils.Delegate/cough - Original Message - From: Fruber Malcome [EMAIL PROTECTED] To: flashcoders@chattyfig.figleaf.com Sent: Saturday, July 07, 2007 11:28 PM Subject: [Flashcoders] XML loading and parsing problem The primary thing to remember is scope. The onLoad function is running within the xml's scope. The fun function is running with the scope of the parent class/object. The fact that fun worked and gallery didn't leads me to think that this is not the real code, but you are running it in a class of some sort. Tehnically in your code, the gallery would be global as well as fun and they should both work, but it sounds more likely that you created your XML object within the scope of a function - I'm not really sure, but here are my thoughts.. I'm not sure what version of AS you are running, so there are slightly better ways to perform this task, but the easy way: Modify your onLoad to pass this on the fun function and modify the fun to have a xmlInfo:XML parameter: gallery.onLoad = function( bSuccess ) { if ( bSuccess ) fun( this ); }; fun( xmlInfo:XML ):Void { // perform your XML stuff. } As a note, Personnaly to keep my onLoad functions short (since they are inline) - I like to pass the boolean to the function as well and check the status there (that way I could do some error handling etc. if necessary). Hope this helps.. Fruber. ___ 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] XML loading and parsing problem
Fruber, i am actually doing a simple gallery that loads pics from an XML file... in as1 as in the project is not that complicated... that's right by the way i found out the problem was the scope.. i'll try it and i'll tell you.. Muzak... why Delegate?? -- Omar M. Fouad - Digital Emotions http://www.omarfouad.net +2010 - 2346633 - +2012 - 261 ___ 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] XML loading and parsing problem
Fruber this code is still not working.. :( var xmlData:XML = new XML(); xmlData.onLoad = function (success) { if(success) { trace(xml Loaded); proceed(this); }else{ trace(xml Not Loaded); } } xmlData.load(gallery.xml); proceed = function (gallery:XML) { totalPics = gallery.childNodes[0].childNodes[0].length; trace(total); } total traces undefined where gallery.xml is ?xml version=1.0? gal catgory pic link=1.jpg code=a1 / pic link=2.jpg code=a2/ pic link=3.jpg code=a3/ pic link=4.jpg code=a4/ /catgory /gal something else missing -- Omar M. Fouad - Digital Emotions http://www.omarfouad.net +2010 - 2346633 - +2012 - 261 -- Omar M. Fouad - Digital Emotions http://www.omarfouad.net +2010 - 2346633 - +2012 - 261 ___ 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] XML loading and parsing problem
i meant trace(totalPics); :P -- Omar M. Fouad - Digital Emotions http://www.omarfouad.net +2010 - 2346633 - +2012 - 261 ___ 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] XML loading and parsing problem
import mx.utils.Delegate; var xmlData:XML = new XML(); xmlData.ignoreWhite = true; xmlData.onLoad = Delegate.create(this, onLoadXML); xmlData.load(gallery.xml); function onLoadXML(success) { if(success) { trace(xml Loaded); proceed(); } else { trace(xml Not Loaded); } } function proceed() { totalPics = xmlData.firstChild.firstChild.childNodes.length; trace(totalPics); } // xml Loaded // 4 Cheers, Claus. Omar Fouad wrote: Fruber this code is still not working.. :( var xmlData:XML = new XML(); xmlData.onLoad = function (success) { if(success) { trace(xml Loaded); proceed(this); }else{ trace(xml Not Loaded); } } xmlData.load(gallery.xml); proceed = function (gallery:XML) { totalPics = gallery.childNodes[0].childNodes[0].length; trace(total); } ___ 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] XML loading and parsing problem
Introduction to XML in Flash http://www.kirupa.com/web/xml/index.htm Textbook example... xmlData = new XML(); xmlData.ignoreWhite = true; xmlData.onLoad = mx.utils.Delegate.create ( this, xml_onLoad ); xmlData.load ( gallery.xml ); function xml_onLoad ( success:Boolean ) { if ( success ) xml_loaded (); else trace( 'nada' ); } function xml_loaded () { var total = xmlData.firstChild.firstChild.childNodes.length; trace ( xml_loaded :: total: + total ); // 4 } _ Jesse Graupmann www.jessegraupmann.com www.justgooddesign.com/blog/ _ -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Omar Fouad Sent: Saturday, July 07, 2007 4:45 PM To: flashcoders@chattyfig.figleaf.com Subject: Re: [Flashcoders] XML loading and parsing problem something else missing -- Omar M. Fouad - Digital Emotions http://www.omarfouad.net ___ 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] XML loading and parsing problem
YESS! thanks DUDE actually it worked without delegate, when i added ignore white...:D On 7/8/07, Claus Wahlers [EMAIL PROTECTED] wrote: import mx.utils.Delegate; var xmlData:XML = new XML(); xmlData.ignoreWhite = true; xmlData.onLoad = Delegate.create(this, onLoadXML); xmlData.load(gallery.xml); function onLoadXML(success) { if(success) { trace(xml Loaded); proceed(); } else { trace(xml Not Loaded); } } function proceed() { totalPics = xmlData.firstChild.firstChild.childNodes.length; trace(totalPics); } // xml Loaded // 4 Cheers, Claus. Omar Fouad wrote: Fruber this code is still not working.. :( var xmlData:XML = new XML(); xmlData.onLoad = function (success) { if(success) { trace(xml Loaded); proceed(this); }else{ trace(xml Not Loaded); } } xmlData.load(gallery.xml); proceed = function (gallery:XML) { totalPics = gallery.childNodes[0].childNodes[0].length; trace(total); } ___ 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 -- Omar M. Fouad - Digital Emotions http://www.omarfouad.net +2010 - 2346633 - +2012 - 261 ___ 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] XML loading and parsing problem
import mx.utils.Delegate; var xmlData:XML; function xmlLoadHandler(success:Boolean) { trace(xmlLoadHandler: +success); trace(xmlData); if(success) { var totalPics:Number = xmlData.firstChild.childNodes[0].childNodes.length; trace(- totalPics: +totalPics); }else{ trace(- failed to load xml data.); } } xmlData= new XML(); xmlData.ignoreWhite = true; xmlData.onLoad = Delegate.create(this, xmlLoadHandler); xmlData.load(gallery.xml); regards, Muzak - Original Message - From: Omar Fouad [EMAIL PROTECTED] To: flashcoders@chattyfig.figleaf.com Sent: Sunday, July 08, 2007 1:44 AM Subject: Re: [Flashcoders] XML loading and parsing problem Fruber this code is still not working.. :( var xmlData:XML = new XML(); xmlData.onLoad = function (success) { if(success) { trace(xml Loaded); proceed(this); }else{ trace(xml Not Loaded); } } xmlData.load(gallery.xml); proceed = function (gallery:XML) { totalPics = gallery.childNodes[0].childNodes[0].length; trace(total); } total traces undefined where gallery.xml is ?xml version=1.0? gal catgory pic link=1.jpg code=a1 / pic link=2.jpg code=a2/ pic link=3.jpg code=a3/ pic link=4.jpg code=a4/ /catgory /gal something else missing -- Omar M. Fouad - Digital Emotions http://www.omarfouad.net +2010 - 2346633 - +2012 - 261 -- Omar M. Fouad - Digital Emotions http://www.omarfouad.net +2010 - 2346633 - +2012 - 261 ___ 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] XML loading and parsing problem
3 people posting similar (allmost identical) examples, all using Delegate should give you a clue ;-) - Original Message - From: Omar Fouad [EMAIL PROTECTED] To: flashcoders@chattyfig.figleaf.com Sent: Sunday, July 08, 2007 2:07 AM Subject: Re: [Flashcoders] XML loading and parsing problem YESS! thanks DUDE actually it worked without delegate, when i added ignore white...:D ___ 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] XML loading and parsing problem
yeah :D On 7/8/07, Muzak [EMAIL PROTECTED] wrote: 3 people posting similar (allmost identical) examples, all using Delegate should give you a clue ;-) - Original Message - From: Omar Fouad [EMAIL PROTECTED] To: flashcoders@chattyfig.figleaf.com Sent: Sunday, July 08, 2007 2:07 AM Subject: Re: [Flashcoders] XML loading and parsing problem YESS! thanks DUDE actually it worked without delegate, when i added ignore white...:D ___ 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 -- Omar M. Fouad - Digital Emotions http://www.omarfouad.net +2010 - 2346633 - +2012 - 261 ___ 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] XML loading and parsing problem
Delegate is a better solution, Since you didn't specify nor show in the code what version of AS you were compiling with, the first version was an AS1 soluction. Delegate is much better, especially if you are using it within a class etc. So if you are using AS2 or better, then that's a more clean solution. Thanks - Fruber -Original Message- From: Muzak [mailto:[EMAIL PROTECTED] Sent: Saturday, July 07, 2007 2:53 PM To: [EMAIL PROTECTED]; flashcoders@chattyfig.figleaf.com Subject: Re: [Flashcoders] XML loading and parsing problem coughmx.utils.Delegate/cough - Original Message - From: Fruber Malcome [EMAIL PROTECTED] To: flashcoders@chattyfig.figleaf.com Sent: Saturday, July 07, 2007 11:28 PM Subject: [Flashcoders] XML loading and parsing problem The primary thing to remember is scope. The onLoad function is running within the xml's scope. The fun function is running with the scope of the parent class/object. The fact that fun worked and gallery didn't leads me to think that this is not the real code, but you are running it in a class of some sort. Tehnically in your code, the gallery would be global as well as fun and they should both work, but it sounds more likely that you created your XML object within the scope of a function - I'm not really sure, but here are my thoughts.. I'm not sure what version of AS you are running, so there are slightly better ways to perform this task, but the easy way: Modify your onLoad to pass this on the fun function and modify the fun to have a xmlInfo:XML parameter: gallery.onLoad = function( bSuccess ) { if ( bSuccess ) fun( this ); }; fun( xmlInfo:XML ):Void { // perform your XML stuff. } As a note, Personnaly to keep my onLoad functions short (since they are inline) - I like to pass the boolean to the function as well and check the status there (that way I could do some error handling etc. if necessary). Hope this helps.. Fruber. ___ 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] XML loading and parsing problem
Omar - also keep in mind all the solutions you are seeing make the assumption that the xml object is global to the context, there are many situations where you only want the xml instance to be around for a short time and keeping it within function scope and then passing a node around or the parsed version of it around - then you should pass the xml object to your function, otherwise if you keep it as a class member (or global) - then all is well. While I'm not 100% sure, I don't think you can make the xml object within a function scope and still use the delegate in this fashion. In that case, you'd need to assign the delegate.create the xml object as the context, with the function being a class member function. But of course the problem with that would be you wouldn't have access to your other class members when the function was called. Unless someone knows of another way - only the AS1 version will allow you to encapsulate the xml object (without having it as a class member or global). Just a few more notes, hope all of it is helpful. Thanks - Fruber -Original Message- From: Muzak [mailto:[EMAIL PROTECTED] Sent: Saturday, July 07, 2007 2:53 PM To: [EMAIL PROTECTED]; flashcoders@chattyfig.figleaf.com Subject: Re: [Flashcoders] XML loading and parsing problem coughmx.utils.Delegate/cough - Original Message - From: Fruber Malcome [EMAIL PROTECTED] To: flashcoders@chattyfig.figleaf.com Sent: Saturday, July 07, 2007 11:28 PM Subject: [Flashcoders] XML loading and parsing problem The primary thing to remember is scope. The onLoad function is running within the xml's scope. The fun function is running with the scope of the parent class/object. The fact that fun worked and gallery didn't leads me to think that this is not the real code, but you are running it in a class of some sort. Tehnically in your code, the gallery would be global as well as fun and they should both work, but it sounds more likely that you created your XML object within the scope of a function - I'm not really sure, but here are my thoughts.. I'm not sure what version of AS you are running, so there are slightly better ways to perform this task, but the easy way: Modify your onLoad to pass this on the fun function and modify the fun to have a xmlInfo:XML parameter: gallery.onLoad = function( bSuccess ) { if ( bSuccess ) fun( this ); }; fun( xmlInfo:XML ):Void { // perform your XML stuff. } As a note, Personnaly to keep my onLoad functions short (since they are inline) - I like to pass the boolean to the function as well and check the status there (that way I could do some error handling etc. if necessary). Hope this helps.. Fruber. ___ 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