# Loading external SWF in AS3

**URL:** <https://forum.kirupa.com/t/loading-external-swf-in-as3/257595>\
**Category:** Uncategorized\
**Created:** [April 15, 2008, 4:09pm UTC](https://forum.kirupa.com/t/loading-external-swf-in-as3/257595 "2008-04-15T16:09:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![stefanmhodgson](https://avatars.discourse-cdn.com/v4/letter/s/f07891/32.png) [@stefanmhodgson](https://forum.kirupa.com/u/stefanmhodgson)\
**Post date:** [April 15, 2008, 4:09pm UTC](https://forum.kirupa.com/t/loading-external-swf-in-as3/257595/1 "2008-04-15T16:09:40Z")

</div>

Hello

I am getting really annoyed with AS3, I know it is probably better for all you coders, but I cannot for the life of my find out how to load an external SWF through the clicking of a button in AS3.

import flash.net.URLRequest;  
import flash.events._;  
import flash.display._;

var PhysTestRequest:URLRequest = new URLRequest(“PhysTest.swf”);  
var PhysTestLoader:Loader = new Loader();

inv\_btn.addEventListener(MouseEvent.MOUSE\_DOWN, newvid);

function newvid(event:MouseEvent):void  
{  
trace(“you clicked me”);  
PhysTestLoader.load(PhysTestRequest);  
addChild(PhysTestLoader);

}  
That is the code that I have cobbled together and I am just getting this error:

TypeError: Error #1009: Cannot access a property or method of a null object reference.  
at General::Input()  
at Main()

Why is this?

If anyone could help me, I would be eternally grateful.

Thanks

Stefan
