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:
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.