Tuesday, November 26, 2013

flex 3 Smooth Scroll Example Enjoy :)








mx|ScrollBar
{
track-skin: Embed(source='assets/scroll/thumb.png',
scaleGridLeft="2", scaleGridTop="6",
scaleGridRight="7", scaleGridBottom="9");
up-arrow-skin: ClassReference("undefined");
down-arrow-skin: ClassReference("undefined");
thumb-up-skin: Embed(source='assets/scroll/thumb_up.png',
scaleGridLeft="3", scaleGridTop="3",
scaleGridRight="10", scaleGridBottom="11");
thumb-over-skin: Embed(source='assets/scroll/thumb_up.png',
scaleGridLeft="3", scaleGridTop="3",
scaleGridRight="10", scaleGridBottom="11");
thumb-down-skin: Embed(source='assets/scroll/thumb_up.png',
scaleGridLeft="3", scaleGridTop="3",
scaleGridRight="10", scaleGridBottom="11");
}

previous 3 Days in java


import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collections;


public class MainApp {

public static void main(String[] args)
{
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
//lendar[] calender = new Calendar[3];
String[] calender = new String[3];
for (int i = 0; i < 3; i++) {
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DATE, -(i+1));
System.out.println(dateFormat.format(calendar.getTime()));
calender[i] = dateFormat.format(calendar.getTime());
}

Collections.reverse(Arrays.asList(calender));
System.out.println("========================================");

for (int i = 0; i < 3; i++) {
System.out.println(calender[i]);
}


}

}

Monday, November 25, 2013

flex Date Formate in datagrid and label


private function formatDateToString(dateObj:Object, column:GridColumn):String
{
var dateFormater:DateFormatter=new DateFormatter();
dateFormater.formatString="DD-MMM-YYYY H:NN:SS A";
var occDate:Date=new Date(Date.parse(dateObj.otAsesDate));
return dateFormater.format(occDate);
}

<s:GridColumn headerText="DATE" dataField="otAsesDate" labelFunction="formatDateToString"/>

---------------------------------------------------------------------------------------------

<s:Image buttonMode="true"
toolTip="Menu"
id="menuIcon"
source="@Embed('assets/images/Circle_Blue32.png')"
click="menuIcon_clickHandler(event)" backgroundColor="#F2F2F2"
mouseDownEffect="{mySounds}"/>
<mx:SoundEffect id="mySounds" source="@Embed('assets/chat_sound.mp3')"/>

-----------------------------------------------------------------------------------------------

<s:Label text="aa.com -" 
fontWeight="bold"
fontSize="18"
click="navigateToURL(new URLRequest('http://www.annadurai.com/'), 'quote')"/>

------------------------------------

private function formatDateToString(formatDate:Date):String
{
var dateFormater:DateFormatter=new DateFormatter();
dateFormater.formatString="DD MMM YYYY L:NN:SS A ";
var dateString:String=dateFormater.format(formatDate);
return dateString;
}


<s:Label text="{formatDateToString(data.time)}"
id="doc99ServerTime"/>
---------------------------------------

var bk:Booking_Popup = new Booking_Popup();
bk.setStyle("addedEffect", image_removedEffect);
bk.setStyle("removedEffect", image_removedEffect);

PopUpManager.addPopUp(bk, this, true);
PopUpManager.centerPopUp(bk);


<mx:Parallel id="image_removedEffect">
<mx:Zoom />
<mx:Fade />
</mx:Parallel>

-----------------------------


[Embed("/assets/RoomBooking/minus.gif")]
[Bindable]
public var minus:Class;














Flex 3 Tool tip Component


<?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"
  height="100%"
  width="100%">

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

import script.ExtendToolTip;

[Bindable]
public var dp:ArrayCollection=new ArrayCollection();
[Bindable]
public var myArray:Array=[1, 2, 3, 4];

[Embed("//assets/images/ic_appo_cal.png")]
[Bindable]
public var patient_photo:Class;

private function createTip(tip:String):ExtendToolTip
{
var imageToolTip:ExtendToolTip=new ExtendToolTip();
//for embeded image
imageToolTip.ImageTip=imgPatient.source;
//for external image
//imageToolTip.ImageTip = "http://l.yimg.com/t/img/new_in_fp_logo.gif";
imageToolTip.TipText=tip;
return imageToolTip;
}
]]>
</fx:Script>

<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<mx:VBox height="100%" width="100%">
<mx:HBox height="50%" width="50%">
<s:Image id="imgPatient"  
source="{patient_photo}"  width="100" height="100" 
toolTip="anna" 
toolTipCreate="event.toolTip=this.createTip(event.currentTarget.toolTip)"  />
<s:Label text="anna"/>
</mx:HBox>
</mx:VBox>
</s:Application>

===========================

ExtendToolTip.as

package script
{
 
import flash.display.Bitmap;
import mx.containers.*;
import mx.controls.Alert;
import mx.controls.Label;
import mx.core.*;
import spark.components.Image;

public class ExtendToolTip extends VBox implements IToolTip
{
private var image:Bitmap = new Bitmap();
private var lbl:Label;
private var imageHolder:Image;
private var tipText:String;
[Bindable]
public function set ImageTip(img:*):void{
if(img is Class){
imageHolder.source = img;
}
if(img is Object){
imageHolder.source = img;
if(img as String){ 
imageHolder.source=img;
}
}
[Bindable]
public function set TipText(txt:String):void{
lbl.text = txt;
}
public function get TipText():String{
return tipText;
}
public function ExtendToolTip()
{
mouseEnabled = false;
mouseChildren = false;
setStyle("percentWidth",50);
setStyle("percentHeight",50);
setStyle("paddingLeft",10);
setStyle("paddingRight",10);
setStyle("paddingTop",10);
setStyle("paddingBottom",10);
setStyle("backgroundAlpha",0.5);
setStyle("backgroundColor",0xffffff);
imageHolder = new Image();
lbl  = new  Label();
lbl.setStyle("color",0x0B0B61);
lbl.setStyle("fontWeight","bold");
lbl.setStyle("fontSize",18);
imageHolder.source = image;
addChild(imageHolder);
addChild(lbl);
}
public function get text():String
{
return null;
}
[Bindable]
public function set text(value:String):void    {
tipText = value;
}
}
}

CustomRowColorDataGrid in flex 3


<?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" xmlns:local="*"
   >
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>

<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
[Bindable]
public var getPatList:ArrayCollection=new ArrayCollection([{id: "Select", value: "Select"}, {id: "Left", value: ""}, {id: 'Right', value: ''}]);


private function setSerialNo(obj:Object, column:int):String
{
var indx:int=getPatList.getItemIndex(obj) + 1;
return String(indx);
}
private function getRowBackgroundColor(item:Object, color:uint):uint{
if( item.value ){
return 0xDA81F5;
}
return color;

}
]]>
</fx:Script>
<local:CustomRowColorDataGrid id="contentAlertDataGrid"
  dataProvider="{getPatList}"
  width="100%"
  height="100%"
  rowHeight="27"
  verticalScrollPolicy="off"
  horizontalScrollPolicy="off"
  resizableColumns="true"
  rowColorFunction="getRowBackgroundColor">
<local:columns>
<mx:DataGridColumn headerText="SNo"
  width="80"
  labelFunction="setSerialNo"/>
<mx:DataGridColumn headerText="RegNo"
  width="80"
  dataField="regNo"/>
<mx:DataGridColumn headerText="DoctorNo"
  width="100"
  dataField="docNo"/>
</local:columns>
</local:CustomRowColorDataGrid>
</s:Application>


===================================================================

package  
{
import mx.controls.DataGrid;
import flash.display.Shape;
import mx.core.FlexShape;
import flash.display.Graphics;
import flash.display.Sprite;
import mx.rpc.events.AbstractEvent;
import mx.collections.ArrayCollection;
import flash.events.Event;
/**
* This is an extended version of the built-in Flex datagrid.
* This extended version has the correct override logic in it
* to draw the background color of the cells, based on the value of the
* data in the row.
**/
public class CustomRowColorDataGrid extends DataGrid
{
private var _rowColorFunction:Function;
public function CustomRowColorDataGrid()
{
super();
}
/**
* A user-defined function that will return the correct color of the
* row. Usually based on the row data.
*
* expected function signature:
* public function F(item:Object, defaultColor:uint):uint
**/
public function set rowColorFunction(f:Function):void
{
this._rowColorFunction = f;
}
public function get rowColorFunction():Function
{
return this._rowColorFunction;
}
// private var displayWidth:Number; // I wish this was protected, or internal so I didn't have to recalculate it myself.
// override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
// {
// super.updateDisplayList(unscaledWidth, unscaledHeight);
// if (displayWidth != unscaledWidth - viewMetrics.right - viewMetrics.left)
// {
// displayWidth = unscaledWidth - viewMetrics.right - viewMetrics.left;
// }
// }
//
/**
*  Draws a row background
*  at the position and height specified using the
*  color specified.  This implementation creates a Shape as a
*  child of the input Sprite and fills it with the appropriate color.
*  This method also uses the <code>backgroundAlpha</code> style property
*  setting to determine the transparency of the background color.
*
*  @param s A Sprite that will contain a display object
*  that contains the graphics for that row.
*
*  @param rowIndex The row's index in the set of displayed rows.  The
*  header does not count, the top most visible row has a row index of 0.
*  This is used to keep track of the objects used for drawing
*  backgrounds so a particular row can re-use the same display object
*  even though the index of the item that row is rendering has changed.
*
*  @param y The suggested y position for the background
*
*  @param height The suggested height for the indicator
*
*  @param color The suggested color for the indicator
*
*  @param dataIndex The index of the item for that row in the
*  data provider.  This can be used to color the 10th item differently
*  for example.
*/
override protected function drawRowBackground(s:Sprite, rowIndex:int,
 y:Number, height:Number, color:uint, dataIndex:int):void
{
if( this.rowColorFunction != null )
{
if( dataIndex < (this.dataProvider as ArrayCollection).length )
{
var item:Object = (this.dataProvider as ArrayCollection).getItemAt(dataIndex);
color = this.rowColorFunction.call(this, item, color);
}
}
super.drawRowBackground(s, rowIndex, y, height, color, dataIndex);
}
}
}

Friday, November 22, 2013

RequestHand.mxml


<?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009" 
xmlns:s="library://ns.adobe.com/flex/spark" 
xmlns:mx="library://ns.adobe.com/flex/mx" width="{this.parentApplication.width}" height="{this.parentApplication.height}"
creationComplete="initApp()">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import com.aavanor.hospaa.utils.MessageUtil;
public function initApp():void
{

MessageUtil.showMessage("Success");;
}
]]>
</fx:Script>
<mx:HBox height="100%"
width="100%">
<mx:HBox height="100%" width="20%" >
</mx:HBox>
<mx:HBox  
height="100%"
width="60%">
<mx:Panel backgroundColor="#ffffff"
 title="Request Hand"
 paddingBottom="50"
 height="100%"
 width="100%">


<mx:VBox height="100%"
paddingBottom="20"
paddingLeft="20"
paddingRight="20"
paddingTop="20"
width="100%">
<mx:HBox height="40%"
width="100%">
<mx:HBox height="100%"
width="50%" horizontalAlign="right"
verticalAlign="middle" >
<mx:HBox>
<mx:Form width="100%">
<mx:FormItem label="Patient Type"
required="true">
<s:TextInput/>
</mx:FormItem>
<mx:FormItem label="Patient Type"
required="true">
<s:TextInput/>
</mx:FormItem>
<mx:FormItem label="Patient Type"
required="true">
<s:TextInput/>
</mx:FormItem>
<mx:FormItem label="Patient"
required="true">
<s:TextInput/>
</mx:FormItem>
<mx:FormItem label="Patient"
required="true">
<s:TextInput/>
</mx:FormItem>
<mx:FormItem label="Patient"
required="true">
<s:TextInput/>
</mx:FormItem>
<mx:FormItem label="Patient"
required="true">
<s:TextInput/>
</mx:FormItem>
<mx:FormItem label="Patient_________"
required="true">
<s:TextInput/>
</mx:FormItem>
<mx:FormItem label="Status"
required="true">
<mx:HBox>
<s:RadioButton id="raAct" label="Active" selected="true"/>
<s:RadioButton id="raInAct" label="InActive"/>
</mx:HBox>
</mx:FormItem>

</mx:Form>
</mx:HBox>
</mx:HBox>
<mx:HBox height="100%" width="50%" 
horizontalAlign="left"
verticalAlign="middle">
<mx:HBox>
<s:Form width="100%">
<s:FormItem label="Aavanor Charge"
required="false"
width="100%">
<s:TextInput />
</s:FormItem>
</s:Form>
</mx:HBox>
</mx:HBox>
</mx:HBox>
<mx:HBox height="5%"
width="100%" horizontalAlign="center"
verticalAlign="middle" >
</mx:HBox>
<mx:HBox height="5%"
width="100%" horizontalAlign="center"
verticalAlign="middle" >
<mx:HBox paddingBottom="5" paddingTop="5">
<s:Button label="Save" id="btnSave"  />
<s:Button label="Status" id="btninActive" />
<s:Button label="Clear" id="btnClear"  />
</mx:HBox>
</mx:HBox>
<mx:HBox height="50%"
width="100%">
<mx:Panel headerHeight="0"
 height="100%"
 
 width="100%">
<mx:VBox height="100%"
width="100%">
 
<s:DataGrid height="95%"
id="dgCharge"
borderVisible="false"
width="100%"  >
<s:columns>
<mx:ArrayList>
<s:GridColumn headerText="Consultant"
 width="240"
 minWidth="50"  
 sortable="false"
 editable="false"/>
 
</mx:ArrayList>
</s:columns>
</s:DataGrid>
</mx:VBox>
</mx:Panel>
</mx:HBox>
</mx:VBox>
</mx:Panel>
</mx:HBox>
<mx:HBox height="100%" width="20%">
</mx:HBox>
</mx:HBox>
</s:Group>

RequestHand.mxml


<?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009" 
xmlns:s="library://ns.adobe.com/flex/spark" 
xmlns:mx="library://ns.adobe.com/flex/mx" width="{this.parentApplication.width}" height="{this.parentApplication.height}"
creationComplete="initApp()">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import com.aavanor.hospaa.utils.MessageUtil;
public function initApp():void
{

MessageUtil.showMessage("Success");;
}
]]>
</fx:Script>
<mx:HBox height="100%"
width="100%">
<mx:HBox height="100%" width="20%" >
</mx:HBox>
<mx:HBox  
height="100%"
width="60%">
<mx:Panel backgroundColor="#ffffff"
 title="Request Hand"
 paddingBottom="50"
 height="100%"
 width="100%">


<mx:VBox height="100%"
paddingBottom="20"
paddingLeft="20"
paddingRight="20"
paddingTop="20"
width="100%">
<mx:HBox height="40%"
width="100%">
<mx:HBox height="100%"
width="50%" horizontalAlign="right"
verticalAlign="middle" >
<mx:HBox>
<mx:Form width="100%">
<mx:FormItem label="Patient Type"
required="true">
<s:TextInput/>
</mx:FormItem>
<mx:FormItem label="Patient Type"
required="true">
<s:TextInput/>
</mx:FormItem>
<mx:FormItem label="Patient Type"
required="true">
<s:TextInput/>
</mx:FormItem>
<mx:FormItem label="Patient"
required="true">
<s:TextInput/>
</mx:FormItem>
<mx:FormItem label="Patient"
required="true">
<s:TextInput/>
</mx:FormItem>
<mx:FormItem label="Patient"
required="true">
<s:TextInput/>
</mx:FormItem>
<mx:FormItem label="Patient"
required="true">
<s:TextInput/>
</mx:FormItem>
<mx:FormItem label="Patient_________"
required="true">
<s:TextInput/>
</mx:FormItem>
<mx:FormItem label="Status"
required="true">
<mx:HBox>
<s:RadioButton id="raAct" label="Active" selected="true"/>
<s:RadioButton id="raInAct" label="InActive"/>
</mx:HBox>
</mx:FormItem>

</mx:Form>
</mx:HBox>
</mx:HBox>
<mx:HBox height="100%" width="50%" 
horizontalAlign="left"
verticalAlign="middle">
<mx:HBox>
<s:Form width="100%">
<s:FormItem label="Aavanor Charge"
required="false"
width="100%">
<s:TextInput />
</s:FormItem>
</s:Form>
</mx:HBox>
</mx:HBox>
</mx:HBox>
<mx:HBox height="5%"
width="100%" horizontalAlign="center"
verticalAlign="middle" >
</mx:HBox>
<mx:HBox height="5%"
width="100%" horizontalAlign="center"
verticalAlign="middle" >
<mx:HBox paddingBottom="5" paddingTop="5">
<s:Button label="Save" id="btnSave"  />
<s:Button label="Status" id="btninActive" />
<s:Button label="Clear" id="btnClear"  />
</mx:HBox>
</mx:HBox>
<mx:HBox height="50%"
width="100%">
<mx:Panel headerHeight="0"
 height="100%"
 
 width="100%">
<mx:VBox height="100%"
width="100%">
 
<s:DataGrid height="95%"
id="dgCharge"
borderVisible="false"
width="100%"  >
<s:columns>
<mx:ArrayList>
<s:GridColumn headerText="Consultant"
 width="240"
 minWidth="50"  
 sortable="false"
 editable="false"/>
 
</mx:ArrayList>
</s:columns>
</s:DataGrid>
</mx:VBox>
</mx:Panel>
</mx:HBox>
</mx:VBox>
</mx:Panel>
</mx:HBox>
<mx:HBox height="100%" width="20%">
</mx:HBox>
</mx:HBox>
</s:Group>

Thursday, November 21, 2013

Flex Samples: About toFixed method of the Number class in Flex


About toFixed method of the Number class in Flex


Returns a string representation of the number in fixed-point notation. Fixed-point notation means that the string will contain a specific number of digits after the decimal point
The following example shows how toFixed(3) returns a string that rounds to three decimal places.
var num:Number = 7.31343;
trace(num.toFixed(3)); // 7.313

The following example shows how toFixed(2) returns a string that adds trailing zeroes.
var num:Number = 4;
trace(num.toFixed(2)); // 4.00

Monday, November 18, 2013

flex Date Formate in datagrid and label


private function formatDateToString(dateObj:Object, column:GridColumn):String
{
var dateFormater:DateFormatter=new DateFormatter();
dateFormater.formatString="DD-MMM-YYYY H:NN:SS A";
var occDate:Date=new Date(Date.parse(dateObj.otAsesDate));
return dateFormater.format(occDate);
}

<s:GridColumn headerText="DATE" dataField="otAsesDate" labelFunction="formatDateToString"/>

---------------------------------------------------------------------------------------------

<s:Image buttonMode="true"
toolTip="Menu"
id="menuIcon"
source="@Embed('assets/images/Circle_Blue32.png')"
click="menuIcon_clickHandler(event)" backgroundColor="#F2F2F2"
mouseDownEffect="{mySounds}"/>
<mx:SoundEffect id="mySounds" source="@Embed('assets/chat_sound.mp3')"/>

-----------------------------------------------------------------------------------------------

<s:Label text="aa.com -" 
fontWeight="bold"
fontSize="18"
click="navigateToURL(new URLRequest('http://www.annadurai.com/'), 'quote')"/>

------------------------------------

private function formatDateToString(formatDate:Date):String
{
var dateFormater:DateFormatter=new DateFormatter();
dateFormater.formatString="DD MMM YYYY L:NN:SS A ";
var dateString:String=dateFormater.format(formatDate);
return dateString;
}


<s:Label text="{formatDateToString(data.time)}"
id="doc99ServerTime"/>
---------------------------------------

var bk:Booking_Popup = new Booking_Popup();
bk.setStyle("addedEffect", image_removedEffect);
bk.setStyle("removedEffect", image_removedEffect);

PopUpManager.addPopUp(bk, this, true);
PopUpManager.centerPopUp(bk);


<mx:Parallel id="image_removedEffect">
<mx:Zoom />
<mx:Fade />
</mx:Parallel>
-----------------------------
[Embed("/assets/RoomBooking/minus.gif")]
[Bindable]
public var minus:Class;

--------------------------------------------------------------------------------

<s:TextInput id="mySelectedTextInput2"
change="filter2()"
borderColor="#CCCCCC"
fontWeight="bold"
width="100%"
toolTip="Type To Search"
color="#808080"
prompt="Type to Search"/>
<s:DataGrid height="95%"
id="dgChargea"
borderVisible="false"
dataProvider="{fieldList}"
click="dgChargea_clickHandler(event)"
width="100%">
<s:columns>

<mx:ArrayList>
<s:GridColumn headerText="S No"
 labelFunction="serialNumb"
 sortable="false"
 editable="false"/>
<s:GridColumn headerText="Field Name"
 dataField="otPrecheckFieldName"/>
<s:GridColumn headerText="Category"
 dataField="categoryName"/>
<s:GridColumn headerText="Status"
 dataField="status"/>
</mx:ArrayList>
</s:columns>
</s:DataGrid>


private function filter2():void
{
fieldList.filterFunction=filterMyArrayCollection2;
fieldList.refresh();
}
private function filterMyArrayCollection2(item:Object):Boolean
{
var searchString:String=mySelectedTextInput2.text.toLowerCase();
var itemName:String=(item.otPrecheckFieldName as String).toLowerCase();
return itemName.indexOf(searchString) > -1;
}
---------------------------------------------------------------------------------