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

<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