7 Replies Latest reply on Jan 16, 2009 10:16 AM by deve.lopez

    Unexpected 1180 Error

    Naughtytrini
      Hello,

      I'm new to the flex world and I'm following an example in a book (Flex 3 Component Solutions) but I get an unexpected 1180 error (Call to a possible undefined method Address) in an example which I can't figure out. I have the attached mxml file and class file. Can anyone help me with the solution to this problem?

      Thanks
        • 1. Re: Unexpected 1180 Error
          seRajan Level 1
          Hi,

          Your Coding working fine. I think you made the mistake in folder creation.

          Your class file should be in folder

          com --> jherrington --> here you class file "Address.as"

          check your folder stucture.

          By
          Rajan
          • 2. Re: Unexpected 1180 Error
            Naughtytrini Level 1
            That worked!

            Thanks
            • 3. Re: Unexpected 1180 Error
              rtalton Level 4
              Since you are using getter/setters methods and private properties, you should also remove the arguments from the class constructor method, since they are not needed and you want them hidden. The getter/setters will handle that.
              By tradition (best practice?) the private properties are declared above the class declaration. You should also always use the "this" keyword in the getters/setters.
              I took the liberty of editing your class to show you an example.
              • 4. Re: Unexpected 1180 Error
                Level 7

                "rtalton" <webforumsuser@macromedia.com> wrote in message
                news:gjli6f$bvr$1@forums.macromedia.com...
                > Since you are using getter/setters methods and private properties, you
                > should
                > also remove the arguments from the class constructor method, since they
                > are not
                > needed and you want them hidden. The getter/setters will handle that.
                > By tradition (best practice?) the private properties are declared above
                > the
                > class declaration. You should also always use the "this" keyword in the
                > getters/setters.

                I think most people don't use "this" when they use underscores in their
                variable name. The underscore implies that the variable is private to the
                class and, hence, couldn't refer to a property of anything but the class
                it's in.


                • 5. Re: Unexpected 1180 Error
                  rtalton Level 4
                  Hey Amy!
                  Yeah, using "this" is a habit I got into because I usually have Bindable public vars in my Value Objects. I use the same names as the public vars for the arguments in the constructor method and differentiate between them by using the this keyword in getters/setters. Didn't want to throw all that at the OP right now... But point well taken regarding the underscore meaning private.
                  Just a habit. Even though it is a New Year, I doubt if I can can swear off doing this.
                  • 6. Re: Unexpected 1180 Error
                    Level 7

                    "rtalton" <webforumsuser@macromedia.com> wrote in message
                    news:gjmbes$dri$1@forums.macromedia.com...
                    > Hey Amy!
                    > Yeah, using "this" is a habit I got into because I usually have Bindable
                    > public vars in my Value Objects. I use the same names as the public vars
                    > for
                    > the arguments in the constructor method and differentiate between them by
                    > using
                    > the this keyword in getters/setters. Didn't want to throw all that at the
                    > OP
                    > right now... But point well taken regarding the underscore meaning
                    > private.
                    > Just a habit. Even though it is a New Year, I doubt if I can can swear off
                    > doing this.
                    >

                    I haven't been able to figure out a resolution. Maybe to stop being self
                    employed and get a real job with benefits LOL.


                    • 7. Re: Unexpected 1180 Error
                      deve.lopez
                      Hello,

                      I am new too and getting the same error.
                      .as file is under src folder under oreilly/cookbook/ sub-folder

                      here is the code of the MXML file first:
                      --------------------------------------------------------
                      <?xml version="1.0" encoding="utf-8"?>
                      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="initApp()">

                      <mx:Object id="person" firstName="John" lastName="Smith" age="50" socialSecurity="123-12-1234"/>

                      <mx:Array>
                      <mx:String>Flex</mx:String>
                      <mx:String>Flash</mx:String>
                      <mx:String>Flash Media Server</mx:String>
                      <mx:String>Flash Lite</mx:String>
                      <mx:String>AIR</mx:String>
                      </mx:Array>

                      <mx:Array>
                      <mx:Array>
                      <mx:String>Flex</mx:String>
                      <mx:String>Flash</mx:String>
                      </mx:Array>
                      </mx:Array>

                      <mx:Canvas>
                      <mx:Script>
                      <![CDATA[
                      import oreilly.cookbook.PersonRenderer;

                      private function buttonClick(event:Event):void
                      {
                      trace(event.target.id);
                      if (event.target.id== "buttonOne")
                      {
                      trace("button one was clicked");
                      }
                      else
                      {
                      trace("button two was clicked I guess");
                      }
                      }

                      private function initApp():void
                      {
                      trace("Hello from Flex Debugging!");
                      }
                      var object:Object = new Object();
                      var otherObject = new Object();
                      //object.other = otherObject;
                      var person2:Object = {name:"John Smith", age:22, position:{department:"Accounting", salary:50000, title:"Junior Accountant"}, id:303};
                      var arr:Array = new Array("red", "blue", "white");
                      var noConstructorArray:Array = [2,4,6,8];

                      var renderer:PersonRenderer = new PersonRenderer();
                      addChild(renderer);
                      ]]>
                      </mx:Script>
                      <mx:VBox horizontalAlign="center" verticalAlign="middle">
                      <mx:HBox width="764">
                      <mx:Button click="buttonClick(event)" label="clik me I am button One" id="buttonOne"/>
                      <mx:Button click="buttonClick(event)" label="clik me I am button Two" id="buttonTwo"/>
                      <mx:Button click="trace('bla bla bal... from another button')" label="clik me I am another button" id="buttonThree"/>
                      <mx:Button click="{textComponent.text = 'You clicked the fourth button'; trace('bla bla bal... from fourth button');}" label="clik me I am the fourth button" id="buttonFour"/>
                      </mx:HBox>
                      <mx:Text text="Text" id="textComponent" />
                      <mx:RichTextEditor/>
                      <mx:HBox>
                      <mx:Script>
                      <![CDATA[
                      private function changeAppearance():void
                      {
                      appearanceButton.width = Number(widthInputField.text);
                      trace(widthInputField.text);
                      appearanceButton.height = Number(heightInputField.text);
                      trace(heightInputField.text);
                      }
                      ]]>
                      </mx:Script>
                      <mx:Image id="imageDisplay"/>
                      <mx:Text text="enter a width"/>
                      <mx:TextInput id="widthInputField"/>
                      <mx:Text text="enter a height"/>
                      <mx:TextInput id="heightInputField"/>
                      <mx:Button click="changeAppearance()" label="change size" id="appearanceButton"/>
                      </mx:HBox>

                      </mx:VBox>
                      </mx:Canvas>
                      </mx:Application>

                      And here is the code of the Package:
                      -------------------------------------------------------
                      // ActionScript file
                      package oreilly.cookbook
                      {
                      import mx.containers.Canvas;
                      import mx.controls.Image;
                      import mx.controls.Text;

                      public class Person
                      {
                      public function Person()
                      {
                      //core code of person goes here
                      }
                      }

                      public class PersonRenderer extends Canvas
                      {
                      private var _data:Object;
                      private var nameText:Text;
                      private var ageText:Text;
                      private var positionText;
                      private var image:Image;

                      public function PersonRenderer()
                      {
                      super();
                      nameText = new Text();
                      addChild(nameText);
                      ageText = new Text();
                      addChild(ageText);

                      ageText.y = 20;
                      positionText = new Text();
                      addChild(positionText);
                      positionText.y = 40;
                      image = new Image();
                      addChild(image);
                      image.y = 60;
                      }

                      override public function set data(value:Object):void
                      {
                      _data = value;
                      nameText.text = value.name;
                      ageText.text = String(value.age);
                      positionText.text = value.position;
                      image.source = value.image;
                      }

                      override public function get data():Object
                      {
                      return _data;
                      }

                      public function retrievePerson():Person
                      {
                      //do some processing here and return Person object
                      return null;
                      }
                      }
                      }