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.

<?php

//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);

mysql_select_db($db_name);

$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:columns>

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

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

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

        </mx:columns>      

    </mx:DataGrid>

  

</mx:Application>

 


And for some nice FLEX application. :)

 

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

[code]

del *.swf

mxmlc main.mxml
[code]

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 Wednesday, July 30, 2008 12:20 AM by lamia
Filed under:

Comments

# re: Hands-on with FLEX

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

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

# re: Hands-on with FLEX

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

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

# Inserting data to MySQL table using Flex and PHP

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

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

# re: Hands-on with FLEX

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

Useful blog. good luck.

# re: Hands-on with FLEX

Tuesday, November 18, 2008 2:06 PM by MuhamedBkkKO

Hi there!

My first post at this great blog!

I wanna show u my dayly updated blog:<a href= http://www.megautbe.cn >Black Amateur  Video</a>

Have a nice day!

BB!

P.S. if you don't want to see this message please write me to no.ads08@gmail.com with subject "NO ADS" and URL of your forum

Thank you for cooperation!

Leave a Comment

(required) 
(required) 
(optional)
(required) 

Enter the numbers above: