2 Replies Latest reply on Oct 23, 2009 2:34 PM by Paul Reilly

    Dropdownlist handler throws error

    Handycam Level 1

      I have this handler for my dropdownlist:

      protected function selectQuality_changeHandler(event:IndexChangeEvent):void {                    
          currentQualityLevel = event.currentTarget.selectedItem.@name;
          counterCostSF = event.currentTarget.selectedItem.@price;}
      

       

       

      As soon as the state that includes this menu is activated, I get the error [code]TypeError: Error #1010: A term is undefined and has no properties.

       

      However, if I continue past the error the app works fine, and people without the debugging plugin get no error.

       

      That menu is populated with xml, and which node is chosen by a menu to the left of it.  I guess it is possible that the data is not ready, but that makes sense to me if the menu is chosen; not just on state load.

       

      Since I don't actually "need" this information until the user uses the menu (there are default values),how can I prevent the error?

       

      Here is the code that controls that menu:

      private function getCountertops_resultHandler(event:ResultEvent):void {
           countertopData = event.result.type;}
      
      protected function selectMaterial_changeHandler(event:IndexChangeEvent):void {
           var sel:int = event.currentTarget.selectedIndex;
           currentMaterial = event.currentTarget.selectedItem.name;
           updateCountertopCard(sel);
       }
                     
      protected function selectQuality_changeHandler(event:IndexChangeEvent):void {                         
          currentQualityLevel = event.currentTarget.selectedItem.@name;
          counterCostSF = event.currentTarget.selectedItem.@price;
      }
                     
      private function updateCountertopCard(i:int):void {
            var node:XML = countertopData[i];
            if (!node) return;
            matTitle.text = countertopData[i].title;
            matCaption.text = countertopData[i].caption;
            matBullets.text = countertopData[i].bullets;
            image1.imageSource = "images/"+countertopData[i]..swatches.swatch[0];
            selectQuality.dataProvider = new XMLListCollection(countertopData[i].cost.level);
            selectQuality.selectedIndex = 0;
            profileList.dataProvider = new XMLListCollection(countertopData[i].profiles.profile);
      }