Calling functios

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

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()

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 :slight_smile:

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.

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)…

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: