2 Replies Latest reply on Jun 6, 2010 8:04 PM by Miggl

    Error #1065: Variable xxx is not defined.

    Miggl Level 1

      Hi All,

      I'm really stumped on this one. I've seen on other forums where they recommend creating a dummy instance to make sure it is compiled into the SWF, but I have that. Also, I have other classes that work just fine.

       

      Here's the code that is failing on the line getDefinitionByName():

       

       

       

       

      var objClass:Class = getDefinitionByName(baseDataType) as Class;

       

       

       

       


      This works with:

      package

       

       

       

       

      com.emmgee.geneomatic.valueObjects

      {

       

      import com.emmgee.datomatic.models.DatOMaticObject;

       

      [

      Bindable]

      [

      Table(name="source_models")]

       

      public class SourceModelVO extends DatOMaticObject

      {

      [

      PrimaryKey]

       

      public var id:int;

       

      public var name:String;

      [

      Column(name="sourcecategory_id")]

       

      public var sourcecategory:SourceCategoryVO;

       

      public var description:String;

       

      public var source_field_id:int;

      }

      }

       

      But not with:

      package

       

       

       

       

      com.emmgee.geneomatic.valueObjects

      {

       

      import com.emmgee.datomatic.models.DatOMaticObject;

       

      [

      Bindable]

      [

      Table(name="source_records")]

       

      public class SourceRecordVO extends DatOMaticObject

      {

      [

      PrimaryKey]

       

      public var id:uint;

      [

      Column(name="sourcemodel_id")]

       

      public var sourceModel:SourceModelVO;

       

      public var title:String;

       

      public var description:String;

      [

      Column(name="is_direct")]

       

      public var isDirect:Boolean;

      [

      Column(name="is_original")]

       

      public var isOriginal:Boolean;

      [

      Column(name="is_primary")]

       

      public var isPrimary:Boolean;

      [

      Column(name="is_legible")]

       

      public var isLegible:Boolean;

      }

      }

       

      In the first case the variable baseDataType reads "com.emmgee.geneomatic.valueObjects::SourceModelVO", and in the second case it reads "com.emmgee.geneomatic.valueObjects::SourceRecordVO".

      The error reads "Error #1065: Variable SourceRecordVO is not defined.

      at global/flash.utils::getDefinitionByName()

      at com.emmgee.datomatic.models::DatOMaticObject/parseMetaData()[C:\Users\Mike\Zend\workspace s\DefaultWorkspace7\Dat-O-Matic\src\com\emmgee\datomatic\models\DatOMaticObject.as:110]

      at com.emmgee.datomatic.models::DatOMaticObject/save()[C:\Users\Mike\Zend\workspaces\Default Workspace7\Dat-O-Matic\src\com\emmgee\datomatic\models\DatOMaticObject.as:61]

      at com.emmgee.geneomatic.modules::Sorcerer/fileSelectHandler()[C:\Users\Mike\Zend\workspaces \DefaultWorkspace7\Gene-O-Matic for the Desktop\src\com\emmgee\geneomatic\modules\Sorcerer.mxml:173]

       

      ", where line 110 is the getDefinitionByName line above.

       

      Any ideas why this is happening with one class, but not the other?

       

      ~Mike

       

      Update:

      This is the oddest thing. So I found another thread that showed how to see if the object is actually loaded in the application domain.

      I instanciated SourceRecordVO in one line (no error), and in the next line the following returned false:

      loaderInfo.applicationDomain.hasDefinition(

      "com.emmgee.geneomatic.valueObjects.SourceRecordVO");

       

      What gives? How can it resolve it in one line, then forget about it in the next??

        • 1. Re: Error #1065: Variable xxx is not defined.
          Miggl Level 1

          Update: I found a thread that showed how to check if the class was loaded in the application domain. So, in my code I instanciate the class on one line and manipulate it without errors, and on the next line I check if its loaded in the application domain, only to find out it isn't! What gives?

           

          [...]

           

           

          this._sourceRecord = new SourceRecordVO();

           

           

          this._sourceRecord.save();

          loaderInfo.applicationDomain.hasDefinition(

          "com.emmgee.geneomatic.valueObjects.SourceRecordVO");

           

          [...]

          • 2. Re: Error #1065: Variable xxx is not defined.
            Miggl Level 1

            One work-around is to add the following compiler parameter:

            -includes=com.emmgee.geneomatic.valueObjects.SourceRecordVO

            I'm not sure why it's not including this specific class in compiled code, while it is include other dynamic classes. I would love to figure that out in order to fix this problem. Thoughts?