Hands-on with FLEX

Note: This post is not intended as a tutorial. I'm just sharing my own personal experience with learning FLEX.

Finally, I was able to sit down for a few hours and do some coding with Flex. Well, I didn't write my own code but I think it helps a lot when you type "most" of the code you copy(you don't have to code everything).

As a learner, I want to reduce as much roadblocks as I can. I want to learn and move forward. So I installed xampp which bundles Apache Webserver and MySQL. It also has PHPMyAdmin. I followed a tutorial from adobe which will teach you how to communicate with PHP. You can find it here.

I had an MXML editor but not a PHP editor so I encountered an error right-away.

XML Parser Failure, I knew right away that I forgot to close a tag that I'm printing through PHP's echo function. I modified the PHP source a bit for my own convenience.


//modified by Lamia, original code written by Mike J. Potter


$host = "localhost";

$username = "root";

$password = ""; //MYSQL bundled with xampp uses an empty space as the default password

$db_name = "flextestdb";


$mysql_connection = mysql_connect($host, $username, $password);


$query = "SELECT * FROM users_tbl";

$result = mysql_query($query);

echo "<people>";

while ( $row = mysql_fetch_object($result) ){

    echo "<person>";

    echo "<userid>" . $row->user_id . "</userid>" ;

    echo "<username>" . $row->username . "</username>";

    echo "<password>" . $row->password . "</password>";

    echo "</person>";



echo "</people>";


The database, the table name and field names are different since I wanted to adhere to my personal way of naming them. Below is the output of the above code. I included the browser output and the HTML source.


If you're working from a blank mxml project in Spket IDE, try pressing ctrl + space to bring-up the code-assist window and type "A", select Application and the mxml skeleton should be generated for you.


Original MXML code written by Mike J. Potter


<?xml version="1.0" encoding="utf-8"?>

<!-- ======================================================================

     Jul 30, 2008 2:23:46 PM                                                      

     ====================================================================== -->

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="rest_service.send()">

    <mx:HTTPService id="rest_service" url="http://localhost/flextest/rest.php"/> 

    <mx:DataGrid left="0" right="0" bottom="0" top="0" dataProvider="{rest_service.lastResult.people.person}">


            <mx:DataGridColumn headerText="Id" dataField="userid"></mx:DataGridColumn>          

            <mx:DataGridColumn headerText="Username" dataField="username"></mx:DataGridColumn>          

            <mx:DataGridColumn headerText="Password" dataField="password"></mx:DataGridColumn>          






And for some nice FLEX application. :)


I tried to create a simple batch program to help me in compiling.


del *.swf

mxmlc main.mxml

In the future, I'll try to see if this can be done with Ant.



Thanks to Mike J. Potter for the wonderful tutorial at the adobe website.

Published 07-30-2008 12:20 AM by lamia
Filed under:


Wednesday, July 30, 2008 1:56 AM by modchip

# re: Hands-on with FLEX

HAYUP! FLEXpert na FLEXpert na talaga si sensei Tim! Turuan mo ako ha. :D

Wednesday, July 30, 2008 3:03 AM by lamia

# re: Hands-on with FLEX

-_-  Basta kaw pre. Pero nde pa ako flexpert, lolz.

Thursday, July 31, 2008 10:49 PM by Lamia's stack and heap based memories...

# Inserting data to MySQL table using Flex and PHP

Ok, in my last post I tried to follow Mike J. Potter's tutorial on how to read data from PHP to Flex

Monday, August 04, 2008 10:10 AM by Cialis Generico

# re: Hands-on with FLEX

Useful blog. good luck.