Thursday, January 29, 2009

Flex UI Tip

While making complex Flex UI, it is very easy to get lost within the COmponent hierarchy, expecially when the hierarchu is very complex and design view is not practical to use.

In this case, here is something which I have found to be extremely helpful:

In your css file, ass borders for the generic components, like this:

Application {
backgroundColor: #ffffff;
border-style:solid;
border-color:#000000;

}
HBox {
border-style:solid;
border-color:#000000;
}

VBox {
border-style:solid;
border-color:#000000;
}

Panel {
border-style:solid;
border-color:#000000;
}

This will add a black border to all components and help you demarcate the boundaries of all the components in use. When you are done, just take them off.

Tuesday, January 27, 2009

The Good House

My lord – this is a good house !!!

Those were the words of a person in UK House of Lords, when one person was caught on tape boasting over payments made to cause changes to legislation.

I try hard to look for a similar incident, and coincidentally – the notes waving scene in Indian Lok Sabha comes to mind.

Is it really any different ? I think not….

Regulation, regulation, regulation – but who will keep an eye on regulators ?

Is the Worldwide Morality Index sinking to a new low in the 21st century ?

I hope not.

Friday, January 23, 2009

[FLEX] Adobe AIR – Local SQL DB – Flex Certification Topics #4.2 & 4.3


#4)  Interacting with data sources and servers:
                # 4.2: Create, connect to and define a local DB.
                # 4.3: Add, Update and Remove records from local database.


Salient Features:

  • Adobe AIR Local SQL DB is stored as a single file on user’s computer. Each DB is stored completely within a single file.
  • AIR Local DB Engine does NOT support foreign key constraints.
  • Classes used to work with Local SQL DB:
    • flash.data.SQLConnection – Corresponding to JDBC Connection
    • flash.data.SQLStatement – Corresponding to JDBC Statement
    • flash.data.SQLResult – Corresponding to JDBC ResultSet
  • Classes related to schema information describing the structure of the database:
    • flash.data.SQLSchemaResult
    • flash.data.SQLTableSchema
    • flash.data.SQLViewSchema
    • flash.data.SQLIndexSchema
    • flash.data.SQLTriggerSchema
  • Classes with constants
    • flash.data.SQLMode
    • flash.data.SQLColumnNameStyle
    • flash.data.SQLTransactionLockType
    • flash.data.SQLCollationType
  • Classes related to events/errors
    • flash.events.SQLEvent
    • flash.events.SQLErrorEvent
    • flash.events.SQLUpdateEvent
    • flash.events.SQLErrorEvent
    • flash.errors.SQLError
  • SQLConnection.open() – Connection is opened in synchronous mode.
  • SQLConnection.openAsync() – Connection is opened in asynchronous mode.
  • If open / openAsync method is called without a parameter, an in memory database is created rather than a file on disk.
  • If open / openAsync method is called with a non-existent file name, that database file is created.
  • Example:


    import flash.data.SQLConnection; 
    import flash.events.SQLErrorEvent;
    import flash.events.SQLEvent;
    import flash.filesystem.File;
    var conn:SQLConnection = new SQLConnection();
    conn.addEventListener(SQLEvent.OPEN, openHandler);
    conn.addEventListener(SQLErrorEvent.ERROR, errorHandler);
    var dbFile:File = File.applicationStorageDirectory.resolvePath("DBSample.db");
    conn.openAsync(dbFile);
    function openHandler(event:SQLEvent):void
    {
    trace("the database was created successfully");
    }
    function errorHandler(event:SQLErrorEvent):void
    {
    trace("Error message:", event.error.message);
    trace("Details:", event.error.details);
    }




  • SQLMode.UPDATE: Open the file for update purpose. Throws an error, if the file does not exist.


  • SQLMode.CREATE: Default. Creates the file if it does not exist.


  • SQLMode.READ: DB is opened for Read-Only operations. No Add, Update or Delete operations can be performed.


  • SQLStatement and named parameters:

    The SQLStatement supports names parameters. The parameters can be used using : or @ syntax.


  • SQLStatement and UNnamed parameters: In this case, the parameters are expressed using ? and assigned using position.


  • SQLStatement:

    • .sqlConnection = conn;


    • .text = “SQL Statement”;


    • .parameters[] = ….


    • .addEventListener(.., ..);


    • .execute()';


    • .getResult()




  • SQLResult

    • .data



FLEX 3 – Basics

 

  • A flex application is delivered as a Flash .SWF file wrapped in html .

Text Controls:

Flex comes with 5 pre-built text controls:
    • Label Control: Presents Single line of text. Used for displaying text. If the text is longer than the width of control, the text is truncated and three dots are added at the end. Change this behavior by adding truncateToFit=false, and the dots will no longer be there. It can display basic HTML tags.
    • Text Control: The text control has word wrapping enabled. Text over multiple lines. It can display basic HTML tags.
    • Text Input: Accepts single line of text.
    • TextArea:  Accepts multiple lines of text.
    • RichTextEdit:

Formatter Classes:

    • CurrencyFormatter
    • DateFormatter
    • NumberFormatter
    • PhoneFormatter
    • ZipCodeFormatter

Image Control

<mx:Image source=”assets/bigben.jpg” />: This downloads the image at runtime. Image is not bundled with the application.

<mx:Image source=”@Embed(‘assets/bigben.jpg’)” />: This embeds the image at compile time. No secondary request to web server. Increases the size of application.

Four kinds of graphics can be loaded dynamically: JPEG,  GIF, PNG, SWF.

Use SWFLoader for showing multiple images.

Monday, January 12, 2009

A Mixed Day

An Indian gets a Golden Globe award for music.

And an Indian company gets banned by World bank.

A mixed day for India as a nation, I would say.

Saturday, January 10, 2009

The Greatest Detective!!!

Hercule Poirot  - who else.

Having watched Agatha Christie’s hero endlessly, I sometimes think why I like him so much. The reasons I would say are – his greatness, his eccentric nature, his aloofness while being a part of it all, i would say appeals to the fish – the sign I belong to.

Its all in the detail – if you spend time with something, it pays off.

Good night & good luck.

Friday, January 09, 2009

Omar Abdullah

For those of you who don’t know, he is the latest chief Minister of the state of Jammu and kashmir in India.

Is he as secular as he pretends he is ?

hmm.. I don’t know. I would like to think that and sincerely hope that all he wants he is the well being of the ‘state’ – that means Jammu, Kashmir and Leh, while being a part of India.

Since winning election and getting to the CM position, he has made quite a few statements stressing upon the ‘separatist’ elements and finding a solution to the ‘Kashmir problem’. That to me seems a problem in itself.

Anyone who has followed that region in the recent past, will know that the solution to that problem lies south to that region, New Delhi to be precise. Whosoever mentions the ‘separatist’ forces, is giving them undue publicity, and I DO NOT believe that Omar is that foolish.

What is his agenda ? I don’t know, but I wish it is pro-India.