Link to home
Start Free TrialLog in
Avatar of joy_de_vivre
joy_de_vivreFlag for Croatia

asked on

Few basic Flex questions

Hello.
I have lots of dilemmas regarding Adobe Flex since I am new in that programming language so I would like you to help me with this. I will compare everything with php/mysql because it's the easiest way to describe what my dilemma is about...

So, my first question is:
when I use php, I like to use lots of 'include' statements in my 'application'. For example, my index.php page usually looks like this:

<?
include("includes/session.php");
include("includes/html_header.php");

if($session->logged_in){
      include ('in/menu.php');
      include ('in/details.php');
      include ('in/other_menu.php');

      if (isset($_GET['c'])) {
            $page = $_GET['c'];
            include ('in/'.$page.'.php');
      } else {
            include ('in/info.php');
      }
} else {
      include ('login_form.php');
}
?>

It doesn't matter what this script does, important thing is that I found some 'flexibility' here and I easily manage everything in my application. I know that Flex can work the same way but I also know that there are few ways to accomplish what I need. For example, I could do it with <mx:State> (and I think it is the most similar to my include() stuff from php), next, I could do  it with  <mx:ViewStack> but I'm not sure if I can 'include' my file in each stack? Then, I can do it with <mx:ToggleButtonBar> etc etc etc.

What is the best option for me here considering that I need to pass variables all around my 'includes'?


Second question:
If i choose to use <mx:State> method for my needs, and in each <mx:State> I include a custom component, how do i send requests from one custom component to another, or to my main application?
For example, i have a page.mxml with some form and a button:
<mx:Button label="submit" id="submitButton"click="login.send();" />
but my HTTPService is in main application file and it looks like this:
<mx:HTTPService id="login" result="something(event)" method="POST" url="some.php"/>
Here I get an error on button which says
1120: Access of undefined property login_user
But if I put exactly same form and button inside my <mx:State> in main application (not including it as a custom component) everything works fine. I am generally confused about that =)


Third question:
Is there a 'standard' iterating through results in Flex? (this probably sounds stupid but I will try to explain)
In php I would use this code to iterate through results:
<?
while($row = mysql_fetsch_array($query)){
      echo $row['blah']
}
?>
I know that there is an thing in Flex which is used for that (dataProvider) but what if I want to get some results from XML and display them as few <mx:Label> which cannot use dataProvider option?


Fourth (and final) quesion:
What is the best way to handle all my queries if I use mysql as my database? For now I made few php files which get data from mysql and generates XML output which I use in Flex. I hope that there is other way than creating php files for each custom query I need. I also wonder how do I insert, update and delete records from mysql with Flex?


I hope you will find some time to explain me even a single thing from my list of mega-noobish questions =)
Thank you for your patience and effort to make me understand these basics =)
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

I really know nothing about FLEX, but I agree with your strategy of using includes, etc. in PHP.  So here are some links that might prove helpful as you go forward

I usually like the SitePoint work:
http://www.sitepoint.com/article/beginners-tutorial-flex-3/

Pete Freitag is also usually pretty good:
http://www.petefreitag.com/item/490.cfm

And Adobe weighs In here...
http://www.adobe.com/devnet/flex/

And 150 page PDF here:
http://www.adobe.com/devnet/flex/pdfs/getting_started_with_Flex3.pdf

For a more general search (apologies for the obvious ;-)
http://www.google.com/search?hl=en&q=beginning+flex+tutorial

Best regards, ~Ray
ASKER CERTIFIED SOLUTION
Avatar of lexxwern
lexxwern
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
And a tip from someone who learnt Flex after doing a lot of PHP:
-- You can seriously consider and properly implement OOP concepts in Flex better than you can in PHP. You should not try to write Flex code the way you would write PHP code. Infact the opposite has happened with me and I am now writing PHP code similar to Flex code.. LOL
Avatar of joy_de_vivre

ASKER

Thanks for this info! It was really helpful =)
And I understand when you say that I will want to code php in a Flex way =) Especially when working in Eclipse =)
Thanks again!
You're welcome. Good luck..