3 Replies Latest reply on Nov 30, 2010 3:48 AM by flex2008

    removechild freezes app

    JoGlez Level 1

      Hi i am making a breadcrumb and when i click on a level I want the sub-levels to dissapear.  I use removeChild to do this and when i remove a child and add another my app freezes.. any tips.. here is the code..

       

      home>>region>>site>>building>>area

       

      //creates linkbutton for breadcrumb- function receives a level which is used for the id. this is repetetive time after time... I removechild with id=region and when i add another one with id=region it freezes... happens whenever I add any crumb after deleting previous ones

      protected function newLink(name:String,level:String):void
                  {
                      var link:LinkButton = new LinkButton();
                      link.label=(level=="home")?name:">>  "+name;
                      link.id = level;
                      breadCrumb.addChild(link);
                      link.addEventListener(MouseEvent.CLICK,function(evt:MouseEvent){goToCrumb(link.id)});
                  }


                  protected function goToCrumb(level:String):void
                  {
                      switch(level)
                      {
                          case 'home':
                              breadCrumb.removeChildAt(4);
                              breadCrumb.removeChildAt(3);
                              breadCrumb.removeChildAt(2);
                              breadCrumb.removeChildAt(1);
                              break;
                          case 'region':
                              breadCrumb.removeChildAt(4);
                              breadCrumb.removeChildAt(3);
                              breadCrumb.removeChildAt(2);
                              break;
                          case 'site':
                              breadCrumb.removeChildAt(4);
                              breadCrumb.removeChildAt(3);
                              break;
                          case 'building':
                              breadCrumb.removeChildAt(4);
                              break;
                          case 'area':
                              Alert.show("You are currently viewing this area");
                             
                      }
                      getInfo(level);               
                  }