10 Replies Latest reply: Jan 10, 2011 7:48 AM by DanelKirch RSS

    I'm confused on how to get started here...??

    Angell EYE Community Member
      I'm trying to create a very simple Flex app that simply returns the eBay official time using their web services. I already have PHP scripts setup to do this and a page that simply prints the eBay time after grabbing it from their API.

      If I understand correctly I should be able to simply create a button in Flex and make it so that when you click that button it calls this PHP page and displays the response in a text element or a grid in my Flex app..??

      What I don't get is how do I make the button actually do that? I've got a Flex app created and I'm in design mode with a button and a Text field dragged onto the design...and now I have no idea what to do next.

      If I can get a quick jump start on how to attach this button to the PHP and display back in the text area I think it'll help me understand a lot better how to move on with Flex.

      Any information would be greatly appreciated. I just can't seem to find a simple sample like this anywhere. Thanks!!
        • 1. Re: I'm confused on how to get started here...??
          SujitG
          Hi,

          Please visit the URL below for details on how to invoke a PHP from Flex application.

          http://livedocs.adobe.com/flex/3/html/data_access_2.html#193905

          You can also access web service directly from the Flex application. Please visit the URL below for more details.

          http://livedocs.adobe.com/flex/3/html/data_access_1.html#110674

          Hope this helps.
          • 2. Re: I'm confused on how to get started here...??
            Gregory Lafrance Community Member
            In this code, change the url of HTTPService to that for your PHP script. Also, change the value of resultFormat to e4x if your PHP script is returning XML. Other changes might be necessary, of course.
            • 3. Re: I'm confused on how to get started here...??
              Angell EYE Community Member
              Thanks for the responses. I'm gonna have to go ahead and put in a lot more time reading over this provided information.

              Greg, thanks a lot! This little script is indeed working exactly as expected, so that's cool. I see how you got the button to act upon clicking and call the web service. I also see how the resultHandler() is working for the most part but I'm getting lost with 'event' and the fact that the function is between CDATA tags, and the import of mx.rpc.events.ResultEvent...how do you even know what imports you need and when..?? LOL, please forgive my ignorance.

              Do you have to hand write most of that type of stuff or are there Design mode ways of adding these things? I don't see an HTTPService control in design mode..?? What language is the resultHandler function even using..?? Is that ActionScript?

              Obviously I've got a lot to read and learn but any quick tips that could be provided here would be appreciated. I'm proficient in PHP and have done a lot web services but never with any kind of cool user interface front-end like flash, or .net, or anything like that. :( I feel lost again, but I need this functionality!
              • 4. Re: I'm confused on how to get started here...??
                Gregory Lafrance Community Member
                Yeah, for this kind of stuff you need to know some things.

                The fact that you are unfamiliar with the <Script> tag, or at least the CDATA section within it, tells me you need to read at least these FB3 help section, and all its sub-sections:

                Flex Programming Elements

                If you do that most of your questions will be answered. I never use design view, so I can't speak to those questions.

                I'll answer some of your questions now.

                The language in the <Script> tag is ActionScript 3. It needs to be wrapped in a CDATA section because otherwise stuff like < & > etc. will be intepreted as bad XML. Remember, the MXML file is an XML file.

                You will know what to import either because you have learned the ActionScript you need to do what you are trying to do, or because you will get errors and then you know you need to import. Sometimes the import statement will be added automatically.

                I always hand code my Flex apps, and never use design mode, because once you get used to it, its not hard, and if you will be coding AS (ActionScript) you will be there anyway. Being able to code AS is where the $$$ will come as Flex grows in popularity. I believe there will be a ton of cash for people good at AS over the next 5 years.

                Read Essential ActionScript and you'll be all set.

                Be aware that events for things like HTTPService are a bit different than events for things like buttons, etc. because they do not get dispatched based on user input. And they are dispatched asynchronously, meaning you call the HTTPService send() method, and you can't depend on the data being available right away. That's why we use the result event.

                Go through the "Flex Programming Elements" and all its sub-sections, and over time, go through the entire FB3 help system, and you will reach Nirvana. I went through most of the FB 2.0.1 help system twice, compiling all the sample programs, a little each day over a four or five month period, and I learned a lot.


                • 5. Re: I'm confused on how to get started here...??
                  Angell EYE Community Member
                  Thanks again for the information. I wasn't thinking too clearly when looking at CDATA. Makes perfect sense. I'm gonna start digging through the ActionScript 3.0 stuff in the Flex help files and hopefully that'll get me rolling.

                  I've just got a particular project that I've done in FileMaker Pro distributing with FM Runtime and I'd really like to move away from it! :)
                  • 6. Re: I'm confused on how to get started here...??
                    Angell EYE Community Member
                    Ok, I just finished up the Lynda.com Essential Training for Flex Builder 3 and I've got a much better handle on things. Still got a ways to go but I like what I see so far. :)

                    One thing this video series didn't mention at all was the ability to create local databases. I was at eBay Live last month and I talked to some guys at the Adobe booth that said I could create local databases and send SQL queries to them just like I'm used to, or of course, use a remote database.

                    I've got a good handle on using a remote database now, but what about local databases so the client can browse through their records even if they don't have an internet connection?

                    I'm coming up short on information regarding this. Thanks!
                    • 7. Re: I'm confused on how to get started here...??
                      Angell EYE Community Member
                      Ah, that's because it's for AIR and these vids were focusing on Flex web apps. I think I found what I need in the help files.
                      • 8. Re: I'm confused on how to get started here...??
                        Gregory Lafrance Community Member
                        Yeah, Flex is really kool, but AIR is where mucho cash will be in the next 5 - 10 years.
                        • 9. Re: I'm confused on how to get started here...??
                          Angell EYE Community Member
                          Will Flex apps run inside mobile flash players for cell phones? Is there an AIR plugin for mobile devices?
                          • 10. Re: I'm confused on how to get started here...??
                            DanelKirch

                            Not in all mobiles...  it mean iOS is excluded, i mean flash player.

                             

                            about air...  its apps can be runned on Android and

                            iOS, but dont know if blackberry yet has had AIR runtime released... it should

                             

                            on symbian/windows i dont think there is any AIR runtime available