2 Replies Latest reply on Aug 8, 2008 8:25 AM by Newsgroup_User

    Progaramatically declare Type

    Level 7
      Hi There

      consider this recursive function:

      private function
      setChildrenEditable(DObj:DisplayObjectContainer,f:Function):void{
      for(var i:int=0;i<DObj.numChildren;i++){
      if (DObj.getChildAt(i) is IContent){
      //do the function
      var c:IContent = DObj.getChildAt(i) as IContent;
      f(c);
      }else if(DObj.getChildAt(i) is DisplayObjectContainer){
      //do the recursion
      setChildrenEditable(DisplayObjectContainer(DObj.getChildAt(i)),f);
      }
      }
      }

      it takes a display object container and recursively sends all children
      of a specific type to function f. What I would like to do is to pass
      the type of child that the method looks for so instead of
      setChildrenEditable(DObj:DisplayObjectContainer,f:Function):void

      it said
      setChildrenEditable(DObj:DisplayObjectContainer,f:Function,Type:???):void

      I could the make it a nice static method for use in lots of different
      situations. Any ideas?


      Cheers Richard