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

<cough>mx.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

Reply via email to