473,386 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Adobe Flex 2.0 confusions

Hi All,

I am developing Employee Management system in Adobe Flex and
I am coding a web service to get data from the database and return
it to Adobe Flex application
but I can find a better way to handle my data in Adobe Flex application.

Is there any sample project to do that, then it will be very helpfull.

Or if anyone can suggest some technology to receive and handle data in
Adobe Flex.

If I want to write data to xml and return to Adobe Flex application then
how well can it handle XML?
Can we serialize xml to classes in Adobe Flex?

Thankyou, for your instant replies.
Oct 5 '07 #1
1 2927
xNephilimx
213 Expert 100+
Hi abbasnaqvi!

Flex 2 uses ActionScript 3, and AS3 introduces a "new" (different from AS2) way of handling XML files, the E4X model. I didn't try it thoroughly, but up to now it seems a pretty strong and stable way to handle XML files.

Your best choice is probably to make a server side script to manage a database and when retriving the data, use XML, I mean, make your server side script return an XML that you will read from your flex app.
To load an XML use the URLLoader Class, set its data format to URLLoaderDataFormat.TEXT, so you retrive the XML as plain text and add a listener to your URLLoader instance to watch for the Complete event, where you will create an XML instance from the text returned from the server.
Something like this:

Expand|Select|Wrap|Line Numbers
  1. import flash.net.URLLoader;
  2. import flash.net.URLLoaderDataFormat;
  3. import flash.net.URLRequest;
  4.  
  5. private function LoadXML():void { //first load the file as you normally would
  6.     var loader:URLLoader = new URLLoader();
  7.     loader.dataFormat = URLLoaderDataFormat.TEXT;
  8.     loader.addEventListener(Event.COMPLETE,onComplete);
  9.     loader.load(new URLRequest("thexml.php")); //I put php since I use this language. I make it return an XML.
  10. }
  11.  
  12. private function onComplete(e:Event):void {
  13.     try {
  14.         var xml:XML = new XML(event.target.data);
  15.         // here you can start parsing your XML file with the E4X model
  16.     } catch (e:TypeError) {
  17.         //if we get here, then the file is not properly formatted as an XML, so it cannot be converted to an XML instance. So do something when you get here, maybe trace something, I don't know
  18.     }
  19. }
  20.  
Parsing an XML with this E4X syntax is very simple, use the elements() method to get all the elements, so you can loop through with a for each (yes, in AS3 they finally included a for each structure, though it works the same as the AS2 version, but wth the fancy name).

Suppose you have an XML like this one (just as an example):

Expand|Select|Wrap|Line Numbers
  1. <employees>
  2.     <employee id="1">
  3.         <name>Guybrush Threepwood</name>
  4.         <position>Pirate</position>
  5.     </employee>
  6.     <employee id="2">
  7.         <name>LeChuck</name>
  8.         <position>Ghost Pirate</position>
  9.     </employee>
  10. </employees>
  11.  
So the AS3 function onComplete would do something like this:

Expand|Select|Wrap|Line Numbers
  1. //I'mm ommiting the try-catch block just to speed this typing up XD
  2. private function onComplete(e:Event):void {
  3.     var xml:XML = new XML(e.target.data)
  4.  
  5.     //to access each employee, just loop through the xml:
  6.     for each(var elem:XML in xml.elements()) {
  7.         //to acces an element's attribute:
  8.         elem.@id;
  9.         //to access an element's content:
  10.         elem.employee.name;
  11.         //to asign it to something you should convert the value to the correct type:
  12.         var eName:String = elem.employee.name.toString();
  13.         var id:Number = Number(elem.@id);
  14.     }
  15. }
  16.  
Of course this code does nothing at all, it's just an example. I'm sure you'll be able to adapt this to your project.

Best regards,
The_Nephilim

Hi All,

I am developing Employee Management system in Adobe Flex and
I am coding a web service to get data from the database and return
it to Adobe Flex application
but I can find a better way to handle my data in Adobe Flex application.

Is there any sample project to do that, then it will be very helpfull.

Or if anyone can suggest some technology to receive and handle data in
Adobe Flex.

If I want to write data to xml and return to Adobe Flex application then
how well can it handle XML?
Can we serialize xml to classes in Adobe Flex?

Thankyou, for your instant replies.
Oct 5 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Peter Kleiweg | last post by:
Hi, I am looking for a Python equivalent of Flex. After some browsing, it seems that Plex is my best bet, but I would like to hear suggestions before I dive in. I have been using Flex a lot...
2
by: olig9 | last post by:
Hello, is there a way to feed an ifstream to a parser generated with flex and bison? I could see that flex wants a FILE* for reading, but I only have an ifstream (actually and ifstream*) for...
5
by: ASP.NET explorer | last post by:
I have been asked to create some simple animation using Adobe Flash player in ASP.NET(C#) web application. While I am fairly well versed with ASP.NET C#, I absolutely have NO IDEA about how to...
10
by: Jules Winfield | last post by:
Guys, I've been designing applications for the financial services industry using MSFT technologies for many years (Win32 API, MFC, and now .NET WinForms). All applications are Internet-based,...
3
by: Tarik Monem | last post by:
Hi Everyone, Still a newbie with FLEX, and I've passed arrays using AJAX to FLEX before, but I've never passed links to FLEX. Basically, this is the OUTPUT, which I wanted, but I'm given an...
1
by: Sells, Fred | last post by:
please excuse slightly off-topic; cannot access turbogears mailing list at the moment. There was an excellent video by James Ward that showed using turbogears to return json data to adoble's flex...
1
by: Sells, Fred | last post by:
Diez wrote: sounds good. Does that "py:strip" remove the <divand anything outside it. I'll be doing a flex style ajax call and it wants just the xml data tree.
3
by: susheela s | last post by:
Hi, Im interested in learning how to create an adobe air application using Flex 3SDK.I need some links to refer.In google i serached about this i got many.But, im confused which one to follow.So,can...
0
by: susheela s | last post by:
Hi. I followed the link which is given below to develop an air application .The procedure i followed is there in this link...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.