3 Replies Latest reply on Oct 1, 2008 3:44 PM by Newsgroup_User

    Reference Error

    Merlyn_MM
      Here is the code and I am getting
      ReferenceError: Error #1069: Property image_1_21 not found on secondMXML and there is no default value.

      When I create the image in mxml I don't get this error but when I do it in ActionScript

      @ App initialization I am creating the images and on click event I am trying to set visibile property to false.

      Any help would be greatly appreciated!

      Thanks!

      public function handleCountyList(event:ResultEvent):void{
      countylist = event.result as ArrayCollection;
      for(var k=1; k<=1; k++){
      for each(var c:Object in countylist){
      var imageProxy:Image=new Image();
      imageProxy.load("1.png");
      imageProxy.height=10;
      imageProxy.width=10;
      imageProxy.x=c.XVAL;
      imageProxy.y=c.YVAL;
      imageProxy.id='image_'+k+'_'+c.COUNTYID;
      imageProxy.visible=true;
      canvas1.addChild(imageProxy);
      }
      }
      }

      public function handleCountyResult(event:ResultEvent):void{
      CountyInfo = event.result as ArrayCollection;
      for(var k=1; k<=3; k++){

      for each(var v:Object in CountyInfo){
      if(['image_'+k+'_'+v.COUNTYID]==true){
      this['image_'+k+'_'+v.COUNTYID].visible=false;
      }

      }

      }
        • 1. Re: Reference Error
          Level 7

          "Merlyn MM" <webforumsuser@macromedia.com> wrote in message
          news:gc0pme$jln$1@forums.macromedia.com...
          > Here is the code and I am getting
          > ReferenceError: Error #1069: Property image_1_21 not found on secondMXML
          > and
          > there is no default value.
          >
          > When I create the image in mxml I don't get this error but when I do it in
          > ActionScript
          >
          > @ App initialization I am creating the images and on click event I am
          > trying
          > to set visibile property to false.
          >
          > Any help would be greatly appreciated!
          >
          > Thanks!
          >
          > public function handleCountyList(event:ResultEvent):void{
          > countylist = event.result as ArrayCollection;
          > for(var k=1; k<=1; k++){
          > for each(var c:Object in countylist){
          > var imageProxy:Image=new Image();
          > imageProxy.load("1.png");
          > imageProxy.height=10;
          > imageProxy.width=10;
          > imageProxy.x=c.XVAL;
          > imageProxy.y=c.YVAL;
          > imageProxy.id='image_'+k+'_'+c.COUNTYID;
          > imageProxy.visible=true;
          > canvas1.addChild(imageProxy);
          > }
          > }
          > }
          >
          > public function handleCountyResult(event:ResultEvent):void{
          > CountyInfo = event.result as ArrayCollection;
          > for(var k=1; k<=3; k++){
          >
          > for each(var v:Object in CountyInfo){
          > if(['image_'+k+'_'+v.COUNTYID]==true){
          > this['image_'+k+'_'+v.COUNTYID].visible=false;
          > }
          >
          > }
          >
          > }

          I already answered this question for you yesterday or the day before, but
          I've added it to the FAQ and maybe the more generic writeup will help.

          Q (10): I have several components with the ID's "component1", "component2",
          "component3", and I want to be able to create a string that contains the
          name of the component so I can change a property on that component. How can
          I do that?

          A: You can refer to any subproperty of an object with a string by
          naming the object and then using the string inside brackets. In this case,
          you just need to figure out what parent to use, and you can get it working.
          Most of the time that you are doing this, the component is in the local
          scope, so the parent will be "this". So, to change the width of component1,
          you can use this['component1'].width=100; .



          The most recent version of the FAQ can always be found at
          http://www.magnoliamultimedia.com/flex_examples/Amys_Flex_FAQ.pdf


          • 2. Re: Reference Error
            Merlyn_MM Level 1
            Thanks for your answer.
            And I did reference the component using 'this'

            this['image_'+k+'_'+v.COUNTYID].visible=false; but it gave me an error. I think I am doing something wrong thats why I have added the code this time.

            Thanks!
            • 3. Re: Reference Error
              Level 7

              "Merlyn MM" <webforumsuser@macromedia.com> wrote in message
              news:gc0s6m$mq0$1@forums.macromedia.com...
              > Thanks for your answer.
              > And I did reference the component using 'this'
              >
              > this['image_'+k+'_'+v.COUNTYID].visible=false; but it gave me an error. I
              > think I am doing something wrong thats why I have added the code this
              > time.
              >
              > Thanks!

              Try tracing out
              trace('image_'+k+'_'+v.COUNTYID)

              to see if what is in there is what you expect.

              I was looking at this line:

              if(['image_'+k+'_'+v.COUNTYID]==true){

              Where there was no this.

              I'm thinking that if that evaluates to true, there is no possible way that
              this['image_'+k+'_'+v.COUNTYID] could possibly evaluate to a component.

              HTH;

              Amy