5 Replies Latest reply on Jun 1, 2009 1:53 PM by injpix

    Calling function in mxml mod

    rckehoe

      I have my main mxml file and then I have a module that I have developed... I want to be able to call a function in that module from my main application... This is what I have done, and it keeps giving an error saying this:

       

      TypeError: Error #1009: Cannot access a property or method of a null object reference.

       

      Here is my code in a nutshell:

       

      Main.mxml

      <mx:WindowedApplication xmlns:mods="mods.*">

           <mx:Script src="general.as" />

           <mods:MyObject id="MyObj" />

           <mx:Button click="LoadObjData();" />

      </mx:WindowedApplication>

       

      general.as

       

      import mods.*;

       

      private function LoadObjData():void {

           MyObj.CustomFunction("Test Data");

      }

       

      mods/MyObject.mxml

      <mx:Script>
              <![CDATA[
             
                  public function CustomFunction(CustData:String):void {
                      MyLabel.text = CustData;
                  }
                 
              ]]>
      </mx:Script>

       

      <mx:Label id="MyLabel" />

       

       

       

      //// Can anyone explain to me what I am doing wrong?