PDA

View Full Version : function scope with different levels



DannyBoyInMarse
May 19th, 2005, 04:40 AM
Hi all,
I'm having a problem calling a function from a different level.
I have my main movie 'Mymovie.swf' in which I add a level(with loadMovie) with this code:
loadMovie("MyNewMovie.swf", "_level1");
On a button in MyNewMovie.swf, I try to call a function in 'Mymovie.swf', by doing:
on(release){
_root.MyFunction();
// or even: _level0.MyFunction();
}
I've tried several ways to do it and looked in the forums. Can anybody help me please,
thanks
Danny
Long Live The Web

DannyBoyInMarse
May 19th, 2005, 03:56 PM
Hi,
I'm answering my own question as someone else might need to know or have a better idea.
Declare the function as a global function in the main swif:
_global.testFunct = function()
{
trace("test this");
}
Then in any swif at any level call the global function:
_global.testFunct();
Simple but may hours looking for the right answer.
tout à loo
DannyBoyInMarseille

scotty
May 20th, 2005, 02:56 AM
Hi,
I'm answering my own question as someone else might need to know or have a better idea...
Thanks for doing so =)

scotty(-: