2 Replies Latest reply on Sep 8, 2011 3:30 PM by home_aidan

    list listen for change does not fire

    home_aidan Level 1

      Hi,

      Ive add a list component successfully with code, now im trying to trigger a method when a user selects an item.

       

      The code I have doesnt trigger though. Does it look correct to you guys?

       

                     var list:List = new List();
                     list.dataProvider = collection
                     
                     list.itemRenderer = new ClassFactory(ItemRend);
                     list.addEventListener(IndexChangeEvent.CHANGE,listItemSelected);
                     list.width = 260;
                     list.height=300;
      
                     var groupH:HGroup = new HGroup();
                     addElement(list);
      
                public function listItemSelected(e:IndexChangeEvent):void{
                     trace("new Item Selected");
                }
      

        • 1. Re: list listen for change does not fire
          drkstr_1 Level 4

          Nothing in that code would seem to indicate a problem.

           

          Can you post a complete test case that demonstrates the issue?

          • 2. Re: list listen for change does not fire
            home_aidan Level 1

            well it extends from vgroup...

            And i use it as part of component for a marker on google maps.

            I think it might have somthing to do with that....

             

            I think I will try  and create this using mxml instead

             

            package com
            {
                 import com.google.maps.overlays.Marker;
                 
                 import flash.events.MouseEvent;
                 import flash.events.TransformGestureEvent;
                 import flash.text.TextField;
                 import flash.text.TextFormat;
                 
                 import mx.collections.ArrayCollection;
                 import mx.core.ClassFactory;
                 import mx.utils.ObjectProxy;
                 
                 import spark.components.Button;
                 import spark.components.HGroup;
                 import spark.components.Image;
                 import spark.components.Label;
                 import spark.components.List;
                 import spark.components.TextArea;
                 import spark.components.TextInput;
                 import spark.components.VGroup;
                 import spark.events.IndexChangeEvent;
                 
                 import views.ItemRend;
            
                 public class InputBox extends VGroup{          
                      public var textBox:TextInput
                      public var marker:Marker
                      //public var markerData:MarkerData;
                      public var button:Button
                      public var areaLetters:Array=[];
                      public var markerInfoData:Object
                      public var collection:ArrayCollection = new ArrayCollection();
                      public var regModel:RegModel = RegModel.getInstance()
                      
                 
                      
                      
                      public function InputBox(){
            
                           
                      }
                      
                      public function iniz():void{
                           this.horizontalAlign = "centre"
                           
                           if(regModel.openMapMarker!=null){
                                regModel.openMapMarker.closeInfoWindow();
                                regModel.openMapMarker=null;
                                
                           }
                           trace("marker "+marker);
                           trace("markerInfoData string "+markerInfoData);
                           
                           for (var F:int = markerInfoData.from; F < markerInfoData.to+1; F++){               
                                //var obj:Object = new Object();
                                //obj.let =regModel.slAlpha[F];
                                
                                var objj:ObjectProxy = new ObjectProxy();
                                objj.let =regModel.slAlpha[F];
                                objj.mainLet =markerInfoData.areaLetter
                                objj.av = true
                                objj.avail = "assets/add-this-plate.png"
                                for (var G:int = 0; G < regModel.foundReges.length; G++){
                                     if(markerInfoData.areaLetter == regModel.foundReges[G].mainLetter && regModel.foundReges[G].secondLetter == regModel.slAlpha[F]){
                                          trace("found one");
                                          objj.av = false;
                                          objj.avail = "assets/avicongotit.png"
                                          break;
                                     }
                                }
                                //if(
                                
                                areaLetters.push(objj);
                           }
                           
                           var closeImg:Image = new Image();
                           closeImg.source = "assets/closeBtn.png"
                           closeImg.width = 50;
                           closeImg.height=50;
                           closeImg.addEventListener(MouseEvent.CLICK,closeOverLay);
                           //var closeButton:Button = new Button();
                           //closeButton.width = 50;
                           //closeButton.height= 50;
                           //closeButton.label="X";
                           var txtFeild:Label = new Label();
                           txtFeild.text = "Completion list for "+markerInfoData.areaName+" ("+markerInfoData.areaLetter+")";
                           txtFeild.width = 215;
                           txtFeild.height=50;          
                           
                           //txtFeild.setStyle("fontSize", 12);
                           //txtFeild.setStyle("textAlign","center");
                           
                           collection.source = areaLetters
                           var list:List = new List();
                           list.dataProvider = collection
                           
                           list.itemRenderer = new ClassFactory(ItemRend);
                           list.addEventListener(IndexChangeEvent.CHANGE,listItemSelected);
                           list.width = 260;
                           list.height=300;
            
                           var groupH:HGroup = new HGroup();
                           //closeButton.addEventListener(MouseEvent.CLICK,closeOverLay);
                           groupH.addElement(txtFeild);
                           groupH.addElement(closeImg);
                           addElement(groupH);
                           addElement(list);
                           
                      }
                      
                      public function listItemSelected(e:IndexChangeEvent):void{
                           trace("new Item Selected");
                      }
                      
            
                      
                      public function closeOverLay(event:MouseEvent):void{               
                           marker.closeInfoWindow();
                           regModel.openMapMarker=null;
                      }
                 }
            }