# Load External Text on Click

**URL:** <https://forum.kirupa.com/t/load-external-text-on-click/319773>\
**Category:** flash\
**Created:** [March 3, 2011, 9:28pm UTC](https://forum.kirupa.com/t/load-external-text-on-click/319773 "2011-03-03T21:28:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![chrisvwebb](https://avatars.discourse-cdn.com/v4/letter/c/ea5d25/32.png) [@chrisvwebb](https://forum.kirupa.com/u/chrisvwebb)\
**Post date:** [March 3, 2011, 9:28pm UTC](https://forum.kirupa.com/t/load-external-text-on-click/319773/1 "2011-03-03T21:28:32Z")

</div>

Alright, so may be I’m an idiot but after playing with this code for hours I’m unsuccessful in getting this to work.

All I want to do is load external text into a text box when I click on a button. I’m trying to execute this in AS3. I know how to do this in AS2 but I need to start working in AS3. Here is the code I’ve been using and keep getting errors. Does anyone see something I don’t?

var loader:URLLoader = new URLLoader();  
loader.load(new URLRequest(“testText.txt”));  
loader.addEventListener(Event.COMPLETE, loadIt);

ohio\_btn.addEventListener(MouseEvent.CLICK, loadIt);

function loadIt(event:MouseEvent):void {  
ohio\_txt.text = event.target.data;  
}

The error I get is “Access of undefined property event.”

Thanks for your help.

Chris
