8 Replies Latest reply on Apr 21, 2010 1:42 PM by Matt Le Fevre

    Calling a FLEX application from html, using parameters

    Florincugir

      Hi guys,

       

      I have this html:

       

      <form name="getTracing" method="POST" action="http://syyzas400/ShipmentInquiry/ShipmentDetails.html">

                QuickTrace 

      <input type="text" name="TrackNbr" size="14" tabindex="1" maxlength="11">

      <br>

       

      Carrier        

      <select name="Carrier" tabindex="2" style="background-color: #D8E4FF; color: black;

                               font-family: Arial; font-weight: bold; font-size: 9pt; width=114">

                <option>Option1

                <option>Option2

                <option>Option3

      </select>

       

      As you can notice, there is an Input field ("TrackNbr") and a selection field ("Carrier") with three options... The user enters a Tracking Nbr.

      in first field  and chooses one of the three options from the second field and hits <enter>. In this moment, as you can see from "action" area, an html (part of a FLEX application) is called. The problem is that the parameters ("TrackNbr" and "Carrier") are not transmitted and I don't know how to do that.

       

      This FLEX application accepts parameters using URL fragments technique (because could be called from another FLEX application, too)

      but obviously this cannot work with the above described form.

       

      I read about External Interface class, but everybody is talking about calling ActionScript functions, not FLEX applications. Being a newbie in this area,

      I am sure I am missing something, but what?

       

      Any help would be very appreciated, as usual...

       

      Florin

       

        • 1. Re: Calling a FLEX application from html, using parameters
          Matt Le Fevre Level 4

          could try using the GET method, and parse the URL on application load

           

          var path:String;
                          
          var URLpath:String = ExternalInterface.call("window.location.href.toString");
          var PassedData:Array = URLpath.split("?");
          
          var Parameteres:Array = PassedData[1].split("&");
          
          
          • 2. Re: Calling a FLEX application from html, using parameters
            pauland Level 4

            Flex uses actionscript, so the ExternalInterface options are perfectly valid and would allow the form to pass variables to an actionscript function that is declared inside a Flex application. Your other alternative besides the URL is to use FlashVars.

             

            You don't mention whether the form is on the html page where the Flex application is active or not - this affects your choices (depending on whether you need to refresh the page).

            1 person found this helpful
            • 3. Re: Calling a FLEX application from html, using parameters
              Florincugir Level 1

              I know FLEX uses ActionScript and I never deny that ExternalInterface is a valid option but I don't know how to use it; should I create a new function which could be called using ExternalInterface and where to pass the parameters? Hmmm, I will give it a try...

              Regarding the FlashVars, I will investigate and try that, too.... (it will, probably, take a while until I have an answer, but you will definitely hear back from me)

               

              Regarding the second part of your answer, I don't know exactly what you mean, but I will try an answer, anyway: on my FLEX screens I have a "Back" button and when it is pressed it goes back (using ExternalInterface) outside the FLEX application (in the initial html page); does that make sense?

               

              Thank you and best regards,

               

               

              Florin

              • 4. Re: Calling a FLEX application from html, using parameters
                Florincugir Level 1

                Hey Grizz..., you lost me a little bit here, buddy, but don't worry, I will do my homework and I will get back to you a.s.a.p. (My background is middle range (AS400) so be good to me!)

                 

                 

                Thanks a lot,

                 

                 

                Florin

                • 5. Re: Calling a FLEX application from html, using parameters
                  pauland Level 4

                  You need to get a basic grounding on how Flex and the flash player relate to html and the refreshing of web pages. I would check out Flex in a Week.

                   

                  There are a ton of tutorials on the web regarding Flashvars and External Interface. It's not possible for you to get a five minute answer until you are a little more familiar with the basic concepts. Google is your friend and will get you to good tutorials first. It will take a little time, but you will get there.

                   

                  Paul

                  1 person found this helpful
                  • 6. Re: Calling a FLEX application from html, using parameters
                    Florincugir Level 1

                    Thanks, Paul, I will do that...

                     

                     

                    Florin

                    • 7. Re: Calling a FLEX application from html, using parameters
                      Florincugir Level 1

                      Problem solved.

                       

                      I got rid of the form tag (and "action", obviously); instead, I created a JavaScript function used for onClick event of the submit button. Inside this function, I captured the values (using getElementById method) of the input and select field and, using these values, I created the URL for my FLEX application (used with location.href property), and BAM! Everything works like a charm... I am even able to use the Back button to exit the FLEX app and return to the selection screen.

                       

                      Now my question is, why does it work??? No complaints at all, just curiosity... I didn't use External Interface class, no exposed ActionScript functions prior calling frm JavaScript, no fancy stuff all sites I saw talking about...

                       

                      Grizz..., I have a feeling that what you described above is a simpler and more advanced way to do about the same thing I did; am I right?

                       

                      Thanks,

                       

                      Florin

                      • 8. Re: Calling a FLEX application from html, using parameters
                        Matt Le Fevre Level 4

                         

                        Grizz..., I have a feeling that what you described below is a simpler and more advanced way to do about the same thing I did; am I right? 

                         

                        Thanks,

                         

                        Florin

                         

                        the way i described makes you handle and manipulate the raw data yourself rather than passing it off to any pre-built functions to handle for you.

                         

                        I imagine both methods work in the same sort of way, mine is just more 'self hands on' and maintainable, whilst the other method is more efficient and new user friendly.

                         

                        But hey, if it works, don't try to fix it