Friday, July 16, 2010

Flex Framework Introduction


Flex


Introduction:

Flex is a programming language that was developed by Adobe technology. It includes all flash features.

                   Flex include two languages.

                   1). MXML

                   2). ActionScript

MXML is a tag-based language while Action Script is a flash language.

Flex coding is done with an XML based language known as MXML.
Flex codes are compiled into a file which has SWF format (Shock Wave Flash) files.
SWF files are executed with stand-alone Adobe's Flash Players.
 It  can also be directly executed in browsers that have Adobe Flash Player Plug-in installed. 


                       
How to run Flex files.

Way 1: Adobe has launched the Flex builder for developing Flex Application. We can download the Flex Builder from Adobe’s website.

Way 2: To compile Flex Application we use Apache Ant technology. Apache’s this technology is used to create a build.xml file that will be used to call the flex compiler for deploying the flex application in Eclipse IDE.

Flex languages

Flex coding involves two different languages MXML and ActionScript respectively.

1). MXML is an extended form of XML and is a tag based language, and so it is called an XML-based markup language. 

2). Flex program files end with .mxml extensions. For example your flex file such as Hello.mxml.

3). MXML used with ActionScript provide tags to separate the GUI components and is used to access the data on servers.

4).  A MXML file is converted into a SWF file that runs on a Flash Player or on a browser which has Adobe Flash Player Plug-in installed in it.

5). ActionScript a flash language is an implementation of ECMAScript  it is similar to OOP based javascript. This is the main programming tool in Adobe Flash Player. It consistes of built-in object and function. It is used to build own object and functions. Its coding is done inside the tag .

We create ActionScript files and call them inside the main MXML file with either 'source' attribute of tag or with 'include' statement inside tag by passing the relative path names of ActionScript files in these attributes. Each and every ActionScript file should be saved with '. as’ extension. 

Way 3:

          Easiest way to run Flex files.
         
          Using flex_sdk_4.1

Step 1). To download flex_sdk_4.1 from

          Step 2). To download apache-ant-1.8.1-bin

          Step 3). To unzip flex_sdk_4.1

Step 4). To unzip apache-ant-1.8.1-bin into same folder where you unzip the  flex_sdk_4.1.
          
For Example I have installed the Flex SDK

E:\InstalledSoftware\flex


Unzip apache-ant-1.8.1-bin into flex folder.



















We stored our flex file into bin folder.

For example E:\InstalledSoftware\flex\bin\Our File

Assume our file is Hello.mxml.

< ?xml version = '1.0' encoding = 'ISO-8859-1'? >
< mx:Application xmlns:mx = 'http://www.adobe.com/2006/mxml' >

< mx:Panel title = ‘Flex Framework’ color = 'green'
paddingLeft = '30' paddingRight = '30'
paddingTop = '30' paddingBottom = '30' >

< mx:Label text = ‘Flex Welcome’ / >
< /mx:Panel >
< /mx:Application >

we have to save this file into E:\InstalledSoftware\flex\bin\Hello.mxml.

Goto command prompt. Click start All Programs and Accessories and command Prompt.

























Go to E:\InstalledSoftware\flex\bin

















Use flex compiler mxmlc to compile the flex file.

Like below screen shot














Go E:\InstalledSoftware\flex\bin. And check the Hello.swf
because the mxmlc create swf file. 



















And open the Hello.swf in the browser.
 























That is all.

Best of luck.

No comments:

Post a Comment