1 Reply Latest reply on Oct 30, 2007 2:08 PM by Gregory Lafrance

    assign a value to object???

    mark416 Level 1
      Hi,

      I try to assign a value to Object like the following code.

      <mx:Script>
      <![CDATA[

      public var emailData:Object;

      public function sendEmaildata():void {

      emailData.email="abc@hotmail.com";

      }

      ]]>
      </mx:Script>

      But I get a error like this " Cannot access a property or method of a null object reference."

      I confuse how to set a value to Object,Please help me.

      Thanks

      M
        • 1. Re: assign a value to object???
          Gregory Lafrance Level 6
          I think you need to have new Object() when you declare your object. Try this code:

          <?xml version="1.0"?>
          <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" initialize="sendEmaildata()">
          <mx:Script>
          <![CDATA[
          [Bindable]
          public var emailData:Object = new Object();

          public function sendEmaildata():void {
          emailData.email="abc@hotmail.com";
          }
          ]]>
          </mx:Script>
          <mx:TextArea id="txtArea" />
          <mx:Button label="Click Me" click="txtArea.text=emailData.email"/>
          </mx:Application>