[Flashcoders] passing a variable to a function
k - sorry for spamming this board all day but it's all been from the same problem i've boiled the whole thing down to this: how do i pass a variable to an onLoad() function? here is my script function loadDescriptions() { for (var i=0; i_root.menuItems_array.length;i++) { var thisTextLoadVars = new LoadVars(); thisTextLoadVars.onLoad = function(success) { trace (_root.menuItems_array[i]); }; var thisDoc = _root.menuItems_array[i]; trace (thisDoc: +thisDoc); var textDoc = _root.menu[thisDoc].description; thisTextLoadVars.load(textDoc); } } the trace in the the onLoad function returns undefined. Can anyone tell me how to get around this please? thanks alz ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] passing a variable to a function
My guess here is that your reference to _root is 'lost' in terms of scope, as you're handling the onLoad event locally (on the stack) within the loadDescriptions() function. Might try this with your current approach: // namespace for this module if(_global.LoadNS == undefined) { _global.LoadNS = this; } function loadDescriptions() { for (var i = 0; i _root.menuItems_array.length; i++) { var thisTextLoadVars = new LoadVars(); thisTextLoadVars.onLoad = function(success) { trace(LoadNS.menuItems_array[i]); }; var thisDoc = _root.menuItems_array[i]; trace(thisDoc: + thisDoc); var textDoc = _root.menu[thisDoc].description; thisTextLoadVars.load(textDoc); } } Hope this helps... -- Dok Skyymap Inc. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of allandt bik-elliott (Receptacle) Sent: Wednesday, November 09, 2005 12:11 PM To: flashcoders@chattyfig.figleaf.com Subject: [Flashcoders] passing a variable to a function k - sorry for spamming this board all day but it's all been from the same problem i've boiled the whole thing down to this: how do i pass a variable to an onLoad() function? here is my script function loadDescriptions() { for (var i=0; i_root.menuItems_array.length;i++) { var thisTextLoadVars = new LoadVars(); thisTextLoadVars.onLoad = function(success) { trace (_root.menuItems_array[i]); }; var thisDoc = _root.menuItems_array[i]; trace (thisDoc: +thisDoc); var textDoc = _root.menu[thisDoc].description; thisTextLoadVars.load(textDoc); } } the trace in the the onLoad function returns undefined. Can anyone tell me how to get around this please? thanks alz ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] passing a variable to a function
That's what I was thinking too. This article may be helpful in this situation http://osflash.org/flashcoders/as2?s=delegate. Judah Glenn J. Miller wrote: My guess here is that your reference to _root is 'lost' in terms of scope, as you're handling the onLoad event locally (on the stack) within the loadDescriptions() function. Might try this with your current approach: // namespace for this module if(_global.LoadNS == undefined) { _global.LoadNS = this; } function loadDescriptions() { for (var i = 0; i _root.menuItems_array.length; i++) { var thisTextLoadVars = new LoadVars(); thisTextLoadVars.onLoad = function(success) { trace(LoadNS.menuItems_array[i]); }; var thisDoc = _root.menuItems_array[i]; trace(thisDoc: + thisDoc); var textDoc = _root.menu[thisDoc].description; thisTextLoadVars.load(textDoc); } } Hope this helps... -- Dok Skyymap Inc. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of allandt bik-elliott (Receptacle) Sent: Wednesday, November 09, 2005 12:11 PM To: flashcoders@chattyfig.figleaf.com Subject: [Flashcoders] passing a variable to a function k - sorry for spamming this board all day but it's all been from the same problem i've boiled the whole thing down to this: how do i pass a variable to an onLoad() function? here is my script function loadDescriptions() { for (var i=0; i_root.menuItems_array.length;i++) { var thisTextLoadVars = new LoadVars(); thisTextLoadVars.onLoad = function(success) { trace (_root.menuItems_array[i]); }; var thisDoc = _root.menuItems_array[i]; trace (thisDoc: +thisDoc); var textDoc = _root.menu[thisDoc].description; thisTextLoadVars.load(textDoc); } } the trace in the the onLoad function returns undefined. Can anyone tell me how to get around this please? thanks alz ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] passing a variable to a function
Yeah, that link actually lays out my own preferred method of executing this. The snippet I put into this thread was just a quick kludge to get that code up and working. Please don't anyone take it as the 'right' approach - my apologies if anyone was mislead... Peace... -- Dok Skyymap, Inc. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Judah Frangipane Sent: Wednesday, November 09, 2005 2:33 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] passing a variable to a function That's what I was thinking too. This article may be helpful in this situation http://osflash.org/flashcoders/as2?s=delegate. Judah Glenn J. Miller wrote: My guess here is that your reference to _root is 'lost' in terms of scope, as you're handling the onLoad event locally (on the stack) within the loadDescriptions() function. Might try this with your current approach: // namespace for this module if(_global.LoadNS == undefined) { _global.LoadNS = this; } function loadDescriptions() { for (var i = 0; i _root.menuItems_array.length; i++) { var thisTextLoadVars = new LoadVars(); thisTextLoadVars.onLoad = function(success) { trace(LoadNS.menuItems_array[i]); }; var thisDoc = _root.menuItems_array[i]; trace(thisDoc: + thisDoc); var textDoc = _root.menu[thisDoc].description; thisTextLoadVars.load(textDoc); } } Hope this helps... -- Dok Skyymap Inc. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of allandt bik-elliott (Receptacle) Sent: Wednesday, November 09, 2005 12:11 PM To: flashcoders@chattyfig.figleaf.com Subject: [Flashcoders] passing a variable to a function k - sorry for spamming this board all day but it's all been from the same problem i've boiled the whole thing down to this: how do i pass a variable to an onLoad() function? here is my script function loadDescriptions() { for (var i=0; i_root.menuItems_array.length;i++) { var thisTextLoadVars = new LoadVars(); thisTextLoadVars.onLoad = function(success) { trace (_root.menuItems_array[i]); }; var thisDoc = _root.menuItems_array[i]; trace (thisDoc: +thisDoc); var textDoc = _root.menu[thisDoc].description; thisTextLoadVars.load(textDoc); } } the trace in the the onLoad function returns undefined. Can anyone tell me how to get around this please? thanks alz ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders