# Event Handling

**URL:** <https://forum.kirupa.com/t/event-handling/316512>\
**Category:** Uncategorized\
**Created:** [November 24, 2010, 3:01am UTC](https://forum.kirupa.com/t/event-handling/316512 "2010-11-24T03:01:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![glisando](https://avatars.discourse-cdn.com/v4/letter/g/e47c2d/32.png) [@glisando](https://forum.kirupa.com/u/glisando)\
**Post date:** [November 24, 2010, 3:01am UTC](https://forum.kirupa.com/t/event-handling/316512/1 "2010-11-24T03:01:43Z")

</div>

Hi Guys…

I am doing some event handling code and am having some problem.  
I have placed the following on the stage, a submit button whose instance name is ‘btnSubmit’ and a label whose instance name is ‘lblTest’. The ActionScript 3 code resides in a separate ‘Maxwell.as’ file. In the ‘Maxwell.FLA’ file, I have typed ‘Maxwell’ in the document class property.  
The following is my AS3 code:

```auto
 
package 
{
 import flash.display.Sprite;
 import flash.events.MouseEvent;
 
 public class Maxwell extends Sprite
 {
  public function Maxwell()
  {
   // constructor code
  }
  private function sendMsg(e:MouseEvent):void
  {
   lblTest.text = "Clicked";
  }
  btnSubmit.addEventListener(MouseEvent.CLICK, sendMsg);
 
 }

```

When I do a ‘CNTRL + ENTER’ and run this program I get the following errors:

**Access of undefined property btnSubmit.**  
**Access of undefined property sendMsg.**

I don’t understand why I am getting these errors. I have already linked up both files by typing ‘Maxwell’ in the document class window and furthermore ‘sendMsg’ is the name of a function. I hope somebody can advise me. Thanks.
