# Calling functios

**URL:** <https://forum.kirupa.com/t/calling-functios/5695>\
**Category:** flash\
**Created:** [September 19, 2002, 5:00pm UTC](https://forum.kirupa.com/t/calling-functios/5695 "2002-09-19T17:00:13Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![g\_esa](https://avatars.discourse-cdn.com/v4/letter/g/2bfe46/32.png) [@g\_esa](https://forum.kirupa.com/u/g_esa)\
**Post date:** [September 19, 2002, 5:00pm UTC](https://forum.kirupa.com/t/calling-functios/5695/1 "2002-09-19T17:00:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 19, 2002, 5:18pm UTC](https://forum.kirupa.com/t/calling-functios/5695/2 "2002-09-19T17:18:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 19, 2002, 5:38pm UTC](https://forum.kirupa.com/t/calling-functios/5695/3 "2002-09-19T17:38:02Z")

</div>

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 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 19, 2002, 6:04pm UTC](https://forum.kirupa.com/t/calling-functios/5695/4 "2002-09-19T18:04:52Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 19, 2002, 8:24pm UTC](https://forum.kirupa.com/t/calling-functios/5695/5 "2002-09-19T20:24:21Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 20, 2002, 6:56am UTC](https://forum.kirupa.com/t/calling-functios/5695/6 "2002-09-20T06:56:30Z")

</div>

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:
