1 Reply Latest reply on Feb 19, 2008 9:58 AM by Gregory Lafrance

    Referencing Objects created by ActionScript

    SonomaIT
      Im using the following bit of code below to create a LinkButtons depending on the total number of callouts.

      Its working great, however, when I try to reference featureNumber in another function in my script, it says that im trying to access an undefined property 'featureNumber'.

      Is there a way I can reference these objects to set certain items?

      for(var i:int = 0; i < totalCallouts; i++) {
      var theLink:LinkButton = new LinkButton;
      newX = 881 + 15 * i;
      theLink.x = newX;
      theLink.y = 261;
      theLink.label = String(i + 1);
      theLink.styleName = "featuresText";
      theLink.width = 20;
      theLink.height = 20;
      theLink.id = 'featureNumber';
      theLink.addEventListener(MouseEvent.CLICK, changeCallout);
      frontCanvas.addChild(theLink);
      }
        • 1. Re: Referencing Objects created by ActionScript
          Gregory Lafrance Level 6
          Define theLink outside of any function and it should be accessible.

          var theLink:LinkButton = new LinkButton();

          for(var i:int = 0; i < totalCallouts; i++) {
          newX = 881 + 15 * i;
          theLink.x = newX;
          theLink.y = 261;
          theLink.label = String(i + 1);
          theLink.styleName = "featuresText";
          theLink.width = 20;
          theLink.height = 20;
          theLink.id = 'featureNumber';
          theLink.addEventListener(MouseEvent.CLICK, changeCallout);
          frontCanvas.addChild(theLink);
          }