Use DeferredInstanceFromFunction : DeferredInstanceFromFunction « Development « Flex

Home
Flex
1.Chart
2.Components
3.Container
4.Data Model
5.Development
6.Effects
7.Event
8.Graphics
9.Grid
10.Style
Flex » Development » DeferredInstanceFromFunctionScreenshots 
Use DeferredInstanceFromFunction
Use DeferredInstanceFromFunction
         

<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
    <mx:Script>
        
            import mx.core.*;
            import mx.states.*;
            [Bindable]
            public var defInst:DeferredInstanceFromFunction = new DeferredInstanceFromFunction(createMyButton);

            public function createMyButton():Object {
                var newButton:Button = new Button();
                newButton.label = "New Button";
                return newButton;
            }
          
    </mx:Script>
    <mx:states>
        <mx:State name="deferredButton">
            <mx:AddChild relativeTo="{myPanel}" targetFactory="{defInst}" />
        </mx:State>
    </mx:states>
    <mx:Panel id="myPanel" title="Static and dynamic states">
        <mx:Button id="myButton2" label="Add" click="currentState ='deferredButton'" />
        <mx:Button id="myButton3" label="Remove" click="currentState =''" />
    </mx:Panel>
</mx:Application>

   
    
    
    
    
    
    
    
    
  
Related examples in the same category
w__w__w___.___ja___v__a2_s_.co___m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.