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>

Thursday, December 20, 2012

.java-examples Program http://www.javatpoint.com

http://www.java-examples.com/java-collections-and-data-structures-%28-java.util-package-%29


Wednesday, December 19, 2012

Saturday, November 17, 2012

Flex 4.5: Customize Scrollbars

<?xml version="1.0" encoding="utf-8"?>
<mx:Application
  xmlns:mx="http://www.adobe.com/2006/mxml"
  layout="absolute"
  creationComplete="onCreationComplete()" viewSourceURL="srcview/index.html">
 
  <mx:Style>
    ScrollBar
    {
      track-skin: Embed(source='assets/track.png',
              scaleGridLeft="2", scaleGridTop="6",
              scaleGridRight="7", scaleGridBottom="9");
      up-arrow-skin: ClassReference("undefined");
      down-arrow-skin: ClassReference("undefined");
    }
   
  </mx:Style>
 
  <mx:Script>
    <![CDATA[
      import mx.utils.UIDUtil;
      import mx.collections.ArrayCollection;
     
      [Bindable]
      private var ac : ArrayCollection;
     
      private function onCreationComplete() : void
      {
        ac = new ArrayCollection();
       
        for (var i:int = 0; i < 25; i ++)
        {
          ac.addItem( UIDUtil.createUID() );
        }
      }
    ]]>
  </mx:Script>
 
  <mx:List width="100%" height="100%"
    dataProvider="{ ac }" />
 
</mx:Application>

Wednesday, November 7, 2012

Drag And Drop In Flex 4.5

<?xml version="1.0"?>
<!-- dragdrop\SimpleListToListMoveSparkDragIndicator.mxml -->
<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"
               creationComplete="initApp();">
    <s:layout>
        <s:VerticalLayout/>
    </s:layout>

    <fx:Script>
        <![CDATA[
            import mx.collections.ArrayCollection;
            import mx.collections.ArrayList;

            [Bindable]
            public var abc:ArrayCollection=new ArrayCollection([{id: "1", value: "one"}]);

            private function initApp():void
            {
                srclist.dataProvider=new ArrayList(['Reading', 'Television', 'Movies']);
                //destlist.dataProvider = new ArrayList([]);
            }
        ]]>
    </fx:Script>

    <s:HGroup>
        <s:VGroup>
            <s:Label text="Available Activities"/>
            <s:List id="srclist"
                    allowMultipleSelection="true"
                    dragEnabled="true"
                    dragMoveEnabled="true"
                    dropEnabled="true"/>
        </s:VGroup>

        <s:VGroup>
            <s:Label text="Activities I Like"/>
            <s:List id="destlist"
                    allowMultipleSelection="true"
                    dataProvider="{abc}"
                    labelField="value"
                    dragEnabled="true"
                    dragMoveEnabled="true"
                    dropEnabled="true"/>
        </s:VGroup>
    </s:HGroup>

    <s:Button id="b1"
              label="Reset"
              click="initApp();"/>
</s:Application>

Monday, November 5, 2012

Adobe Flex – Format Date & Time (inside of a DataGrid too)

<mx:DateFormatter id="formatDateTime" formatString="MM/DD/YY" />
 
 
the formatString will determine how your date & time is formatted. I have created a pattern chart below that’s a little easier to read then the one on Adobe’s Flex Documentation.
Pattern Example
Year  
YY 09 (Year Number Short)
YYY 2009 (Year Number Full)
YYYY 02009 (I have no clue why you would need this)
Month  
M 7 (Month Number Short)
MM 07 (Month Number Full)
MMM Jul (Month Name Short)
MMMM July (Month Name Full)
Day  
D 4 (Day Number Short)
DD 04 (Day Number Full)
Day Name  
E 1 (Day Number Short)
EE 01 (Day Number Full)
EEE Mon (Day Name Short)
EEEE Monday (Day Name Full)
A AM/PM
J Hour in day (0-23)
H Hour in day (1-24)
K Hour in AM/PM (0-11)
L Hour in AM/PM(1-12)
N 3 (Minutes)
NN 03 (Minutes)
SS 30 (Seconds)
OK now on to applying it to a date with funky database formatting

<mx:DateFormatter id="formatDateTime" formatString="MM/DD/YY" />
 
 
 
<mx:DataGridColumn headerText="Date">
     <mx:itemRenderer>
          <mx:Component>
               <mx:VBox>
                    <mx:DateFormatter id="formatDateTime" formatString="MM/DD/YY" />
                    <mx:Label text="{formatDateTime.format(data.myDate) }/>