0 Replies Latest reply on Oct 5, 2007 2:48 PM by pgherveou

    Defer canvas creation

    pgherveou
      Hello everybody

      When I start my flex application I load dynamically in AS several tabs to a tabNavigator with the addChild method like in the following code


      var canvas : Canvas = new Canvas();
      canvas.label = "Dynamic Canvas";
      canvas.addEventListener(FlexEvent.CREATION_COMPLETE, function (event : Event) : void {Alert.show('Dynamic canvas created');});
      tabnav.addChild(canvas);


      When I do that the canvas is automatically created and the creation complete event is dispatched
      What I would like to do is to create the object only when the tab is selected later by the user

      Basically I would like to reproduce the effect of this mxml code where the canvas is 'completed' only when the user select the tab

      <mx:TabNavigator id="tabnav" x="143" y="108" width="465" height="341">
      ...
      <mx:Canvas label="Canvas number n" width="100%" height="100%" creationComplete="Alert.show('Canvas n created');">
      </mx:Canvas>
      </mx:TabNavigator >


      Thanks for your help if you have any idea of how to do that