# Flash 6 - Calling a function on an external swf timeline

**URL:** <https://forum.kirupa.com/t/flash-6-calling-a-function-on-an-external-swf-timeline/260098>\
**Category:** flash\
**Created:** [May 12, 2008, 4:32pm UTC](https://forum.kirupa.com/t/flash-6-calling-a-function-on-an-external-swf-timeline/260098 "2008-05-12T16:32:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kaylee](https://avatars.discourse-cdn.com/v4/letter/k/e56c9b/32.png) [@kaylee](https://forum.kirupa.com/u/kaylee)\
**Post date:** [May 12, 2008, 4:32pm UTC](https://forum.kirupa.com/t/flash-6-calling-a-function-on-an-external-swf-timeline/260098/1 "2008-05-12T16:32:23Z")

</div>

I’ve tried looking everywhere for this answer, but I’m still at a loss. I’m beginning to think it’s not possible or I’m just not looking in the right places.

I have three swf files. The main container and then two external swf files being loaded into the main swf. Swf 1 (frame.swf) has a function on the main timeline that needs to be called from a button in swf 2 (toolbox.swf). My initial thought was to place the actionscript of frame.swf into a movieclip and call it from toolbox.swf using:

\_root.callFunction(“PH”, “doPhone”);

Although this would work, I cannot use this option. The actionscript of \*swf 1 \*must stay in the main timeline. Using a class file is not an option either. Is there any other way to call a function from the main timeline of an external swf?

---

<div class="post-metadata">

**Author:** ![sparkdemon](https://avatars.discourse-cdn.com/v4/letter/s/958977/32.png) [@sparkdemon](https://forum.kirupa.com/u/sparkdemon)\
**Post date:** [May 13, 2008, 9:15am UTC](https://forum.kirupa.com/t/flash-6-calling-a-function-on-an-external-swf-timeline/260098/2 "2008-05-13T09:15:04Z")

</div>

var mc1:MovieClip=\_root.createEmptyMovieClip(“target”,0);// swf with the function  
loadMovie(“a.swf”,mc1);

var mc2:MovieClip=\_root.createEmptyMovieClip(“btn”,1);// swf with the button  
loadMovie(“b.swf”,mc2);

onEnterFrame=function()  
{  
if((mc2.getBytesLoaded()\>=mc2.getBytesTotal())&&(mc2.getBytesTotal()\>0))  
{  
if((mc1.getBytesLoaded()\>=mc1.getBytesTotal())&&(mc1.getBytesTotal()\>0))  
{  
delete this.onEnterFrame;  
mc2.btn.onPress=function()  
{  
mc1.colorMe(); // call your function  
}  
}  
}  
}

[quote=kaylee;2325117]I’ve tried looking everywhere for this answer, but I’m still at a loss. I’m beginning to think it’s not possible or I’m just not looking in the right places.

I have three swf files. The main container and then two external swf files being loaded into the main swf. Swf 1 (frame.swf) has a function on the main timeline that needs to be called from a button in swf 2 (toolbox.swf). My initial thought was to place the actionscript of frame.swf into a movieclip and call it from toolbox.swf using:

\_root.callFunction(“PH”, “doPhone”);

Although this would work, I cannot use this option. The actionscript of \*swf 1 \*must stay in the main timeline. Using a class file is not an option either. Is there any other way to call a function from the main timeline of an external swf?[/quote]
