Avatar of joy_de_vivre
Flag for Croatia asked on

Few basic Flex questions

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 ('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 =)
Adobe FlashApache FlexPHP

Avatar of undefined
Last Comment

8/22/2022 - Mon
Ray Paseur

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:

Pete Freitag is also usually pretty good:

And Adobe weighs In here...

And 150 page PDF here:

For a more general search (apologies for the obvious ;-)

Best regards, ~Ray

View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.

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

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!
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy

You're welcome. Good luck..