View Full Version : Calling functios
g_esa
September 19th, 2002, 01:00 PM
Hi,
I've got al little problem. I want to call a function in my "Scene 2" from my "Scene 1". How can I do this. I've already tried:
functienaam();
but this does not work!
Does someone know how to call a funtions in another scene?
Thanx
jsk
September 19th, 2002, 01:18 PM
I'm using Flash5
I've just defined a function on the main timeline in Scene 1 Frame 1 and invoked it without any problems in Scene2 Frame 1 using the code:
Scene1 Frame1
function speak() {
trace("hello there")
}
Scene2 Frame1
speak()
pom
September 19th, 2002, 01:38 PM
Careful with the scope. If you do what jsk said, the speak function is in the _root, so if you call it from somewhere else than the _root, you'll have to use _root.speak();
pom :)
flex
September 19th, 2002, 02:04 PM
Yes. It's the same as targetting an mc or referring to variables. If the function or variable is in an mc called "bob" you'd use _root.bob.function(); or _root.bob.bobscore.
eyezberg
September 19th, 2002, 04:24 PM
And you can't call a function before it's declared, so calling function A in scene 1 from scene 2 is ok, but calling function B in scene 2 from scene 1 won't work (doesn't exist yet)..
upuaut
September 20th, 2002, 02:56 AM
I believe, also, if you declare a function inside of a movie clip and that movie clip ceases to exist on the timeline, you can no longer call that function.
any other rules of thumb that you guys can think of? we should doc them all here. :nerd:
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.