5 Replies Latest reply on Jul 20, 2009 1:20 AM by ma.tze

    Replace Canvas with Group!??

    ma.tze Level 1

      Hi,

       

      I tried to replace the Canvas with a group in the following code

       

      This works fine:

       

      1.)

      <mx:TabNavigator id="tn" width="100%" height="100%"> ...

       

      private function AddForm():void{
          var children:Array=tn.getChildren();
          var form:myCanvas=new myCanvas;
          tn.addChild(form);
          form.label="Form" + (children.length+1).toString();
          tn.selectedChild=form;
      }

       

      2.)

      I tried to do the same with a group, this have several problems:

       

      private function AddGroup():void{
          var children:Array=tn.getChildren();
          var form:myGroup=new myGroup;
          tn.addChild(form);

                // runtime: TypeError: Error #1034: Type Coercion failed: cannot convert myGroup@f02ec29 to mx.core.Container.


          form.label="Form" + (children.length+1).toString();

                // compile error 1119: Access of possibly undefined property label through a reference with static type myGroup.    TestModuleService.mxml              TestModuleService/src    line 78    Flex Problem
          tn.selectedChild=form;

                //compile error 1067: Implicit coercion of a value of type myGroup to an unrelated type mx.core:Container.    TestModuleService.mxml              TestModuleService/src    line 80    Flex Problem
      }

       

      Is it possible to achieve the same result as 1.) using a group?

       

      Thanks for any pointers!

       

      Martin Zach