Friday, April 17, 2009

Adobe AIR


Adobe integrated runtime is a cross-platform environment for building rich internet application using Adobe flash, Adobe flex , HTML and AJAX that can be deployed as a desktop application. This environment helps the developers to use their web development skills, tools and codes to develop a application that runs without the support of a browser.

Important Dates:
Air, once called as Apollo gave extension for developing application with the flex framework on March 19, 2007.
A stable Linux version of AIR was released on October 1, 2007.
Adobe AIR 1.1 was released on June 16, 2008.

Both the deployment paradigms provide advantage as well as disadvantage. Say, for a rich internet application developed in browser doesn't need any installation, but the application that is developed using flex must be downloaded, checked for certificate and finally installed in the desktop. In the same way a the user can get lots of freedom in accessing the file in his local system using the application developed in AIR since it s in local, on the other hand a browser application has got lots of restriction and security issues in accessing and storing data in the local.



AIR applications can operate offline, and then activate further functionality or upload data when an active Internet connection becomes available.

Thursday, April 16, 2009

<STYLE> <DIV> <SPAN>

<div> and <span> are two different useful and powerful tools when dealing with cascading style sheet. Both the tags are used to describe the contents that cannot be properly described by other HTML tags because these tags supports additional formatting capabilities both for inline elements and block elements.
On the other hand <style> tag provides a way to define style rules within the documents <head> tag. The style rules may help the developers to set the visual attributes like color,size,algnments to the elements that are displayed.

<DIV>
Div (short for division) divides the content into individual sections. Each section can then have its own formatting, as specified by the CSS. Div is a block-level container, meaning that there is a line feed after the tag.
For example, if we have the following CSS declaration:
.large { color: #00FF00; font-family:arial; font-size: 4pt; }
The HTML code
<div class="large"> This is a DIV sample. </div>
gets displayed as
This is a DIV sample.

<Span>

Span is similar to div in that they both divide the content into individual sections. The difference is that span goes into a finer level, so we can span to format a single character if needed. There is no line feed after the tag.
For example, if we have the following CSS declaration:
.largefont { color: #0066FF; font-family:arial; font-size: 6px; }
The HTML code
Span is not at the <span class="largefont">block level.</span>
gets displayed as
Span is not at the block level.

Differences and default behavior

div and span differ from each other in one regard. In standard HTML, a div is a block level elements (and so visually isolates a section of a document on the page, in the same way as a paragraph) whereas a span is an inline element (for containing a piece of information inline with the surrounding text). In practice, even this feature can be changed by the use of CSS.

<STYLE>

Whenever a browser reads a style sheet, it will format the document according to it. In the early version of html, it is only used to markup the text. The layout of the document was supposed to be taken care of by the browser, without using any formatting tags. But as the HTML grown with new tags and attributes(such as font and color), it become more complicated for a browser to differentiate tag and text.

To solve this problem, the World Wide Web Consortium (W3C) - the non profit, standard setting consortium, responsible for standardizing HTML - created STYLES in addition to HTML 4.0. All major browsers support Cascading Style Sheets.
Usage

External Style Sheet

An external style sheet is ideal when the style is applied to many pages. With an external style sheet, you can change the look of an entire Web site by changing one file. Each page must link to the style sheet using the <link> tag. The <link> tag goes inside the head section.
<head> <link rel="stylesheet" type="text/css" href="mystyle.css"> </head>

Internal Style Sheet

An internal style sheet should be used when a single document has a unique style. You define internal styles in the head section with the <style> tag.
<head> <style type="text/css"> body {background-color: red} p {margin-left: 20px} </style></head>

Inline Styles

An inline style should be used when a unique style is to be applied to a single occurrence of an element.
To use inline styles you use the style attribute in the relevant tag. The style attribute can contain any CSS property. The example shows how to change the color and the left margin of a paragraph:

<p style=" margin-left: 20px"> This is a paragraph </p>

Monday, April 6, 2009

Train Scheduler in Flex

This component is developed to illustrate the use and usage of most of the basic components.
The basic components that are used in this application are :
  1. Labels
  2. Image box
  3. Combo box
  4. Canvas
  5. Check boxes
  6. Timer
  7. and Datagrid
The output of the application gets a look as

This is a simple example which gives us some detailed idea about the data binging between components. The check boxes in the canvas gets exchanged based upon the event of combo box.
A timer runs getting the local time from the system. Then a datagrid gets input from a xml file and shows it.
And the source for the above application comes here.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" backgroundColor="white" backgroundImage="@Embed(source='background.jpg')" alpha="0.49" cornerRadius="5" themeColor="#1884C9" xmlns:local="*" creationComplete="showTime()">
<mx:XMLList xmlns="" id="trainDetails">
<trains>
<name>bangalore Mail</name>
<number>2352</number>
<picture>vidhana-soudha-in-bangalore.jpg</picture>
</trains>
<trains>
<name>Kovai Express</name>
<number>4545</number>
<picture>kovai.jpg</picture>
</trains>
<trains>
<name>Nizamuddin Express</name>
<number>9320</number>
<picture>nizamiddin.jpg</picture>
</trains>
<trains>
<name>pandyan Express</name>
<number>2548</number>
<picture>panyan.jpg</picture>
</trains>
<trains>
<name>Rockfort Express</name>
<number>5896</number>
<picture>rockfort.jpg</picture>
</trains>
<trains>
<name>Mumbai Express</name>
<number>8569</number>
<picture>mumbai.jpg</picture>
</trains>
<trains>
<name>Cochin Express</name>
<number>1201</number>
<picture>cochin.jpg</picture>
</trains>
<trains>
<name>Secundrabad Express</name>
<number>8523</number>
<picture>secundrabad.jpg</picture>
</trains>
</mx:XMLList>

<mx:Script>
<![CDATA[
import mx.formatters.DateFormatter;
import mx.controls.Alert;

private var arrive:Array;
private var departure:Array;
private var ticker:Timer;
[Bindable] private var time:String;

public function showTime():void
{
var currentTime:Date = new Date();
var timeFormat:DateFormatter = new DateFormatter;
timeFormat.formatString = "KK:NN:SS"; //"HH:NN:SS" for 24hr clock
time=currentTime.hours+":"+currentTime.minutes+":"+currentTime.seconds;
ticker = new Timer(1,1);
ticker.addEventListener(TimerEvent.TIMER_COMPLETE,onTimerComplete);
ticker.start();
}

public function onTimerComplete(event:TimerEvent):void{
showTime();
}

private function reshedule(event:Event):void{
arrive=arrivalForm.getChildren();
departure=departureForm.getChildren();
if(schedulerCB.selectedLabel=="Move to Departures"){
for each(var aname:CheckBox in arrive){
if(aname.selected==true){
arrivalForm.removeChild(aname);
departureForm.addChild(aname)
aname.selected=false;
}
}
schedulerCB.selectedItem=action[0];
}
else if(schedulerCB.selectedLabel=="Move To Arrivals"){
for each(var dname:CheckBox in departure){
if(dname.selected==true){
departureForm.removeChild(dname);
arrivalForm.addChild(dname);
dname.selected=false;
}
}
schedulerCB.selectedItem=action[0];
}
}

private function selectAll(event:Event):void{
if(event.currentTarget.id=="arrivalAllLB"){
arrive=arrivalForm.getChildren();
for each(var status:CheckBox in arrive)
status.selected=true;
}
else{
departure=departureForm.getChildren();
for each(var status:CheckBox in departure)
status.selected=true;
}
}

private function selectNone(event:Event):void{
if(event.currentTarget.id=="arrivalNoneLB"){
arrive=arrivalForm.getChildren();
for each(var status:CheckBox in arrive)
status.selected=false;
}
else{
departure=departureForm.getChildren();
for each(var status:CheckBox in departure)
status.selected=false;
}
}
]]>
</mx:Script>

<mx:Array id="action">
<mx:Object label="--SELECT--"/>
<mx:Object label="Move To Arrivals"/>
<mx:Object label="Move to Departures"/>
</mx:Array>
<mx:Canvas width="1328" height="658">
<mx:ComboBox x="414" y="109" id="schedulerCB" dataProvider="{action}" change="reshedule(event);" borderColor="#338CCA" color="#E88FA0"/>
<mx:Text x="164" y="43" text="SOUTHERN RAILWAYS TRAIN SCHEDULE " fontSize="36" fontFamily="Georgia" width="803" textDecoration="underline" fontStyle="italic" color="#F56C21" height="58"/>
<mx:Image x="57" y="25" source="Indian_Railways_logo.png"/>
<mx:Panel title="Train Details" paddingTop="10" paddingLeft="10" paddingRight="10" x="817" y="111" height="396" borderColor="#BA8383" width="501">
<mx:DataGrid id="databaseDG" width="450" height="100%" rowCount="5" dataProvider="{trainDetails}">
<mx:columns>
<mx:DataGridColumn dataField="name" headerText="name"/>
<mx:DataGridColumn dataField="number" headerText="number"/>
</mx:columns>
</mx:DataGrid>

<mx:Form width="455" height="180" verticalScrollPolicy="off" horizontalScrollPolicy="off">
<mx:HBox width="435" height="163" >
<mx:VBox>
<mx:FormItem label="Individual Train Details" fontWeight="bold" fontSize="12">
</mx:FormItem>
<mx:FormItem label="Train Name" fontSize="12">
<mx:Label text="{databaseDG.selectedItem.name}" width="151"/>
</mx:FormItem>
<mx:FormItem label="Train Number" fontSize="12">
<mx:Label text="{databaseDG.selectedItem.number}"/>
</mx:FormItem>
</mx:VBox>
<mx:Image source="{databaseDG.selectedItem.picture}" width="176" height="140"></mx:Image>
</mx:HBox>
</mx:Form>
</mx:Panel>
<mx:Canvas id="arrivalCan" x="146" y="148" width="312" height="460">
<mx:Form id="arrivalForm" x="15" y="89" width="276" height="361" backgroundAlpha="1.0" backgroundColor="gray" borderColor="#B20808" color="#850303">
<mx:CheckBox id="bangloreCB" label="Bangalore Mail" borderColor="#09EB99" fontSize="21" fontFamily="Georgia" color="#FFFFFF" fillAlphas="[1.0, 1.0]" fillColors="[#090202, #090202]" themeColor="#DEF804" cornerRadius="10" alpha="1.0"/>
<mx:CheckBox id="kovaiCB" x="52" y="58" label="Kovai Express" color="#FFFFFF" borderColor="#09EB99" fontSize="21" fontFamily="Georgia" fillAlphas="[1.0, 1.0]" fillColors="[#090202, #090202]" themeColor="#DEF804" cornerRadius="10" alpha="1"/>
<mx:CheckBox id="nizamCB" x="47" y="217" label="Nizamuddin Express" borderColor="#09EB99" fontSize="21" fontFamily="Georgia" color="#FFFFFF" fillAlphas="[1.0, 1.0]" fillColors="[#090202, #090202]" themeColor="#DEF804" cornerRadius="10" alpha="1.0"/>
<mx:CheckBox id="pandyCB" x="47" y="302" label="Pandyan Express" borderColor="#09EB99" fontSize="21" fontFamily="Georgia" color="#FFFFFF" fillAlphas="[1.0, 1.0]" fillColors="[#090202, #090202]" themeColor="#DEF804" cornerRadius="10" alpha="1.0"/>
</mx:Form>
<mx:Label x="78" y="10" text="ARRIVALS" fontSize="27" fontWeight="bold"/>
<mx:Label x="62" y="61" text="Select:" fontSize="12" fontWeight="bold" color="#1C6DBF"/>
<mx:LinkButton id="arrivalAllLB" x="126" y="59" label="All" alpha="0.0" color="#1C6DBF" click="selectAll(event); "/>
<mx:LinkButton id="arrivalNoneLB" x="190" y="59" label="None" alpha="0.0" color="#1C6DBF" click="selectNone(event);"/>
</mx:Canvas>
<mx:Canvas id="departureCan" x="483" y="148" width="326" height="460">
<mx:Form id="departureForm" x="22" y="81" width="284" height="369" backgroundAlpha="1.0" backgroundColor="gray" borderColor="#B20808" color="#850303">
<mx:CheckBox id="rockfortCB" x="53" y="22" label="Rockfort Express" borderColor="#09EB99" fontSize="21" fontFamily="Georgia" color="#FFFFFF" fillAlphas="[1.0, 1.0]" fillColors="[#090202, #090202]" themeColor="#DEF804" cornerRadius="10" alpha="1.0"/>
<mx:CheckBox id="mumbaiCB" x="53" y="103" label="Mumbai Express" borderColor="#09EB99" fontSize="21" fontFamily="Georgia" color="#FFFFFF" fillAlphas="[1.0, 1.0]" fillColors="[#090202, #090202]" themeColor="#DEF804" cornerRadius="10" alpha="1.0"/>
<mx:CheckBox id="cochinCB" x="53" y="185" label="Cochin Express" borderColor="#09EB99" fontSize="21" fontFamily="Georgia" color="#FFFFFF" fillAlphas="[1.0, 1.0]" fillColors="[#090202, #090202]" themeColor="#DEF804" cornerRadius="10" alpha="1.0"/>
<mx:CheckBox id="secudCB" x="53" y="266" label="Secundrabad Mail" borderColor="#09EB99" fontSize="21" fontFamily="Georgia" color="#FFFFFF" fillAlphas="[1.0, 1.0]" fillColors="[#090202, #090202]" themeColor="#DEF804" cornerRadius="10" alpha="1.0"/>
</mx:Form>
<mx:Label x="52" y="10" text="DEPARTURE" fontSize="28" fontWeight="bold"/>
<mx:Label x="37" y="59" text="Select:" fontSize="12" fontWeight="bold" color="#1C6DBF"/>
<mx:LinkButton id="departureAllLB" x="101" y="57" label="All" alpha="0.0" color="#1C6DBF" click="selectAll(event);"/>
<mx:LinkButton id="departureNoneLB" x="165" y="57" label="None" alpha="0.0" color="#1C6DBF" click="selectNone(event);"/>
</mx:Canvas>
<mx:Label x="949" y="42" text="TIME : {time}" fontSize="34" fontWeight="bold" textDecoration="underline"/>
</mx:Canvas>
</mx:Application>


If you find it difficult to trace the code, download the source of trainscheduler.mxml here and arrange the supporting file like the images for the different trains. Then that example must work fine.

Work it out and dont forget to comment me ..

Thursday, April 2, 2009

Video Resume

April 1st, End of the first month after joining in chipkidz. To evaluate myself a video session was shoot to record my experience and knowledge i gain working in chipkidz. Here comes the video.