6 Replies Latest reply on Jun 10, 2006 1:14 AM by ur_dtrain

    Access of undefined property

    coolshare
      I am new to Actionscript and have some basic questions

      I tried to compile following codes but got an error "Access of undefined property em".
      What I tried to do was
      - create an instance of EventManager
      - access a function of the instance

      I am a javascript guy and
      did it in a javascript way. I really appreciate if anyone point out what was wrong?


      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="vertical">

      <mx:Script>
      <![CDATA[
      public var em:EventManager = new EventManager();
      em._registerEvent("validate", function validate() {
      mx.controls.Alert.show(null, 'Enter validation');
      ...
      });
      ]]>
      </mx:Script>
      <mx:Form width="420" height="297">
      ...
      mx:Form>
      </mx:Application>



      Here is the EventManager.as:

      package {
      public class EventManager
      {

      public function _registerEvent(eType:String, handler:Function)
      {
      ...
      }
      ...
      }
      }