Monday, August 12, 2013

flex datagrid header need to write image or component enjoy :)

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
               xmlns:s="library://ns.adobe.com/flex/spark"
               xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <fx:Script>
        <![CDATA[
            import mx.collections.ArrayCollection;
            [Bindable]
            public var arr:ArrayCollection = new ArrayCollection([{id:"1",value:"anna"} , {id:"2",value:"durai"} ]);
                                                               
           
        ]]>
    </fx:Script>
    <mx:HBox height="100%" width="100%">
        <s:DataGrid height="100%" dataProvider="{arr}" width="100%">
            <s:columns>
                <mx:ArrayList>
                    <s:GridColumn dataField="id" >
                                               
                    </s:GridColumn>
                    <s:GridColumn dataField="value">
                        <s:headerRenderer>
                            <fx:Component>
                                <s:DefaultGridHeaderRenderer>
                                    <mx:HBox height="100%" width="100%">
                                        <mx:Image source="./addNew.png" />
                                    </mx:HBox>
                                </s:DefaultGridHeaderRenderer>
                            </fx:Component>
                        </s:headerRenderer>
                        <s:itemRenderer>
                            <fx:Component>
                                <s:GridItemRenderer>
                                    <mx:HBox backgroundColor="red" height="100%" width="100%">
                                        <s:TextInput />
                                    </mx:HBox>
                                </s:GridItemRenderer>
                            </fx:Component>
                        </s:itemRenderer>
                    </s:GridColumn>
                </mx:ArrayList>
            </s:columns>
        </s:DataGrid>
    </mx:HBox>
</s:Application>

Wednesday, July 31, 2013

Wednesday, July 3, 2013

Using ModuleLoader events in flex

 
http://livedocs.adobe.com/flex/3/html/help.html?content=modular_6.html
 
<?xml version="1.0"?>
<!-- modules/EventApp.mxml -->
<mx:Application xmlns="*" xmlns:mx="http://www.adobe.com/2006/mxml">
    <mx:Script>
        <![CDATA[
            [Bindable]
            public var selectedItem:Object;
        ]]>
    </mx:Script>
    <mx:ComboBox 
        width="215" 
        labelField="label" 
        close="selectedItem=ComboBox(event.target).selectedItem"
    >
        <mx:dataProvider>
            <mx:Object label="Select Coverage"/>        
            <mx:Object 
                label="Life Insurance" 
                module="insurancemodules/LifeInsurance.swf"
            />
            <mx:Object 
                label="Auto Insurance" 
                module="insurancemodules/AutoInsurance.swf"
            />          
            <mx:Object 
                label="Home Insurance" 
                module="insurancemodules/HomeInsurance.swf"
            />
        </mx:dataProvider>
    </mx:ComboBox>

    <mx:Panel width="100%" height="100%">
        <CustomModuleLoader id="mod" 
            width="100%" 
            url="{selectedItem.module}"
        />
    </mx:Panel>
    <mx:HBox>
        <mx:Button label="Unload" click="mod.unloadModule()"/> 
        <mx:Button label="Nullify" click="mod.url = null"/>
    </mx:HBox>  
</mx:Application> 
 
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- modules/CustomModuleLoader.mxml -->
<mx:ModuleLoader xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*" creationComplete="init()">
  <mx:Script>
    <![CDATA[
    public function init():void {
        addEventListener("urlChanged", onUrlChanged);
        addEventListener("loading", onLoading);
        addEventListener("progress", onProgress);
        addEventListener("setup", onSetup);
        addEventListener("ready", onReady);
        addEventListener("error", onError);
        addEventListener("unload", onUnload);

        standin = panel;
        removeChild(standin);        
    }
    
    public function onUrlChanged(event:Event):void {
        if (url == null) {
            if (contains(standin))
                removeChild(standin);
        } else {
            if (!contains(standin))
                addChild(standin);
        }
        progress.indeterminate=true;
        unload.enabled=false;
        reload.enabled=false;
    }

    public function onLoading(event:Event):void {
        progress.label="Loading module " + url;
        if (!contains(standin))
            addChild(standin);

        progress.indeterminate=true;
        unload.enabled=false;
        reload.enabled=false;
    }
    
    public function onProgress(event:Event):void {
        progress.label="Loaded %1 of %2 bytes...";
        progress.indeterminate=false;
        unload.enabled=true;
        reload.enabled=false;
    }
    
    public function onSetup(event:Event):void {
        progress.label="Module " + url + " initialized!";
        progress.indeterminate=false;
        unload.enabled=true;
        reload.enabled=true;
    }
    
    public function onReady(event:Event):void {
        progress.label="Module " + url + " successfully loaded!";
        unload.enabled=true;
        reload.enabled=true;

        if (contains(standin))
            removeChild(standin);
    }
    
    public function onError(event:Event):void {
        progress.label="Error loading module " + url;
        unload.enabled=false;
        reload.enabled=true;
    }
    
    public function onUnload(event:Event):void {
        if (url == null) {
            if (contains(standin))
                removeChild(standin);
        } else {
            if (!contains(standin))
                addChild(standin);
        }
        progress.indeterminate=true;
        progress.label="Module " + url + " was unloaded!";
        unload.enabled=false;
        reload.enabled=true;
    }
    
    public var standin:DisplayObject;
    ]]>
  </mx:Script>

  <mx:Panel id="panel" width="100%">
    <mx:ProgressBar width="100%" id="progress" source="{this}"/>
    <mx:HBox width="100%">
      <mx:Button id="unload" 
        label="Unload Module" 
        click="unloadModule()"
      />
      <mx:Button id="reload" 
        label="Reload Module" 
        click="unloadModule();loadModule()"
      />
    </mx:HBox>
  </mx:Panel>
</mx:ModuleLoader> 

Monday, June 24, 2013

Adobe Flex 3 UI Components Lifecycle « Armindo Cachada's Blog: Struts 2, Adobe Flex and ATG



1) preInitialize: This event is raised when the component has just been created but none of the child components exist.
2) initialize: This event is raised after the component and all its children have been created but before any dimensions have been calculated.
3) creationComplete: This even is dispatched after all the component and its children have been created and after all the layout calculations have been performed.
4) applicationComplete: Dispatched after all the components of an application have been successfully created



<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"
preinitialize="preInitialise()"
initialize="initialise()"
applicationComplete="applicationComplete()"
creationComplete="creationComplete()"
viewSourceURL="srcview/index.html">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;

[Bindable]
private var eventsCalled:ArrayCollection=new ArrayCollection();

public function preInitialise():void
{
eventsCalled.addItem({label: "preInitialise called", event: "preInitialise"});
}

public function initialise():void
{
eventsCalled.addItem({label: "initialise called", event: "initialise"});
}

public function creationComplete():void
{
eventsCalled.addItem({label: "creation complete called", event: "creationComplete"});
}


public function applicationComplete():void
{
eventsCalled.addItem("applicationComplete called");
}
]]>
</mx:Script>
<mx:TabNavigator width="400"
height="400">
<mx:Canvas label="tab1">
<mx:DataGrid id="datagrid"
dataProvider="{eventsCalled}"
top="10"
left="10"
width="300"/>
</mx:Canvas>
<mx:Canvas label="tab2">
<mx:Label text="This label is created only when it is displayed"
 creationComplete="creationComplete();"
 preinitialize="preInitialise();"
 initialize="initialise();"/>
</mx:Canvas>

</mx:TabNavigator>
</mx:Application>

Thursday, June 20, 2013

public var info:IModuleInfo;
            public var customModule:ModuleLoader;
import spark.modules.ModuleLoader;
            protected function hbx_creationCompleteHandler():void
            {
                isIPflag=true;
               

                info =
                    ModuleManager.getModule( "Module.swf");
                info.load();
                customModule = new ModuleLoader;
                var url1:String = "Module.swf";
                customModule.loadModule(url1);
                hbx.removeAllElements();
                hbx.addElement(customModule);
               
               
            }
    <s:HGroup id="hbx"
                                          height="100%"
                                          width="100%" creationComplete="hbx_creationCompleteHandler()">
                                </s:HGroup>


Saturday, December 22, 2012

Loading cascading style sheets on the fly using the Flex StyleManager class

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2007/12/12/loading-cascading-style-sheets-on-the-fly-using-the-flex-stylemanager-class/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle">

    <mx:Script>
        <![CDATA[
            import mx.styles.StyleManager;

            private function loadStyles(styleURL:String):void {
                StyleManager.loadStyleDeclarations(styleURL);
            }
        ]]>
    </mx:Script>

    <mx:ApplicationControlBar dock="true">
        <mx:ComboBox id="comboBox"
                prompt="Please select a style"
                change="loadStyles(comboBox.selectedItem.data);">
            <mx:dataProvider>
                <mx:Array>
                    <mx:Object label="red" data="styles/red.swf" />
                    <mx:Object label="green" data="styles/green.swf" />
                    <mx:Object label="blue" data="styles/blue.swf" />
                </mx:Array>
            </mx:dataProvider>
        </mx:ComboBox>
    </mx:ApplicationControlBar>

</mx:Application>