Flex Builder Archives

Count Up Timer

A simple flex application for the implementation of the Timer, which can have buttons for Start, Pause and Reset.

Program:-


Screen Shot:-

You will frown when you see flash builder 4 instead of flex builder 4 which you expected. The reason is that flex builder is officially renamed to flash builder from version 4 onwards. Now i will explain you how to upgrade a project from 3 to 4. It is really easier than having a cup of tea.
Read the rest of this entry

Flex gradient background

A simple thing that I learnt today in Flex (I am very much a beginner as you can see) – adding a gradient to the flex background.

This will add a horizontal gradient starting from light gray and ending in black – looks real nice.

Remember to prefix your color codes with 0x (zero and alphabet x) – and not #

Incoming search terms:

  • light gradent for flex

Remote access using Flex

This program sends a URL request to the server and then the response is received  and the content is displayed in a formatted way……

The output is ……….

Count Up Timer

A simple Flex application for Count Up Timer in which one can Start , Pause and Reset it.

Program:

Screen Shot:

Incoming search terms:

  • timer count up on button click in android

Bank Interest Calculation Using Flex

It is an application to calculate simple and compound interest.

Accept user input for principle amount(P),year(N),interest rate(R).

Here it can calculate both simple and compound interest.

Simple interest is calculated using the mathematical formulae I = PNR/100 and

compound inetrest can be calculated using I = (P(1+r/100)^N)-P

Code for the calculation is as follows:

Output must be shown like follows:

Here you are going to connect a Flex application with PHP.
The values are saved as an XML format in that PHP file.

You can create a new Flex Project and paste the following code in the mxml file:

Here you are going to use <mx:XML> which connects the mxml application with a php file.
Then an <mx:DataGrid> is used which shows a datagrid with specified columns.

Then create a folder inside /xamp/htdocs/
Here I have created a folder named flex and inside that folder create a new php file which I named as products.php
Copy the code below into products.php

Here in the  php file, data is saved in XML format and it is printed inside the datagrid defined in the mxml file.

Start Xamp and run the mxml file in Adobe Flex.
You can see a data grid with populated values.

Flex – PHP – MySQL

Example — Employee listing from ‘employee’ table

First Create a PHP file, which connects to the data base, query the table, retrieve the value and store it in a XML file.

list.php

Now we need to wrap a Flex user interface around the XML list.php page. Create a data viewer for XML data that comes from PHP with Flex.
list.mxml file, used for this is copied below.

The <mx:XML> tag defines the location of XML data source. Its our list.php file.
<mx:DataGrid> tag is a Flex control that displays data in a tabular format.
To tell the DataGrid control which fields to display, create an <mx:columns> tag that contains <mx:DataGridColumn> tags for each field.

Example — Insert data into ‘employee’ table

First Create a PHP file, which connects to the data base, prepares the INSERT statement, and runs it with the variables provided by the POST arguments that will come from the Flex application. Flex applications use POST data just like any other web client, which makes it easy to connect with existing web applications.

addEmployee.php

The next step is to build the frontend form that will add employee to table. This form uses the addEmployee.php script on the server to add new entries to the database. The MXML script for the form is shown below.

At the top of the file is the definition of the HTTP service that the PHP addEmployee.php script provides.

At the bottom is the form, with all the labels, text input areas and “Add Employee” button.

Connecting Flex with php

1. Go to File > New > Flex Project.
2. In the dialog box, type helloWorld as the project name, and specify a project directory called helloWorld under the web root. Select Web application option as the application type, and then select an application server type of PHP.
3. Also give main source folder name
4. In the design view change value for layout as ‘vertical’.
5. Write following code in helloworld.mxml of code view.
We can use an HTTPService component with any kind of server-side technology, including PHP pages.Here ,the service has an ID of phpService and a URL pointed to the helloWorld.php file, and the result format is generic object. The service is also set to call the showResult() function when it gets a result.
To actually use the service, its send method needs to be called.
For that we use <mx:Button> control .
<mx:Button label=”Call PHP” click=”phpService.send()”/>
Now, we need to create the showResult() function in an <mx:Script> block, below the <mx:HTTPService> tag.

7. Run the application to get the result as shown below.