# Access the actionscript code of an externally loaded swf

**URL:** https://forum.kirupa.com/t/access-the-actionscript-code-of-an-externally-loaded-swf/326015
**Category:** Uncategorized
**Created:** [November 17, 2011, 12:55pm UTC](https://forum.kirupa.com/t/access-the-actionscript-code-of-an-externally-loaded-swf/326015 "2011-11-17T12:55:35Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![jeancnicolas](https://avatars.discourse-cdn.com/v4/letter/j/7bcc69/32.png) [@jeancnicolas](https://forum.kirupa.com/u/jeancnicolas)
#### Post date: [November 17, 2011, 12:55pm UTC](https://forum.kirupa.com/t/access-the-actionscript-code-of-an-externally-loaded-swf/326015/1 "2011-11-17T12:55:35Z")

</div>

I know in AS2 I could do this pretty easily … But am unsure of the syntax approach of AS3.

I want to have a main movie which will load in an external swf, which has AS code in its timeline. Then I wish to access the functions inside this external swf and control them from the ‘controller’ swf (the main movie).

Any ideas? this is what I propose ::::

```auto
// Main Movie

var swfLoader:Loader = new Loader();
var swfFile:URLRequest = new URLRequest("external-file.swf");
var container:MovieClip= new MovieClip();
swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, swfLoadedHandler);
var currentSWF:MovieClip = new MovieClip();

function swfLoadedHandler(e:Event):void 
{
    trace("swf loaded");
    currentSWF = MovieClip(swfLoader.content);  
    currentSWF.executeFunction(); 
}
container.addChild(swfLoader);
swfLoader.load(swfFile);

//-------------------------------------------------//

// External SWF

function executeFunction():void
{
    trace("call from external swf");    
}

```

from this - “call from external swf” should trigger …  
Right!?
