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

Reply via email to