24 Replies Latest reply on Apr 23, 2010 4:32 PM by Flex harUI

    How do I replace the SWF?

    Jerry62712 Level 1

      In certain cases I want to remove the swf file and replace it with an XML string.  There won't be a wrapper as Adobe tech support found a way to input a parameter, but only if it is the swf file.  In those cases where there is a parameter I want to do a calculation and totally replace what is in the browser with XML data.

       

      We currently do this with java, but I'm trying to convert that to Flex.

        • 1. Re: How do I replace the SWF?
          Flex harUI Adobe Employee

          I think you'd be better off having a wrapper, otherwise you have to redirect

          to a new url that contains your xml.

          • 2. Re: How do I replace the SWF?
            Jerry62712 Level 1

            Thanks for the idea.  I was told by Flex support that the way to get the parameter to the application was to have it go to the SWF directly and not through a wrapper.  If the wrapper could work and the output be written instead of the SWF I'd literally jump for joy.

             

            My management is demanding results and I can't blame them, but I'm not getting the results either.  It works in the existing java application and they don't see why a newer technology should fail to achieve the same thing.  I have to report back to them by noon today on any results or failure.  Sigh.  Are we having fun yet?

            • 3. Re: How do I replace the SWF?
              Flex harUI Adobe Employee

              Might be past noon your time.  I'm not clear what you did in Java to achieve

              in the same.

               

              Any Flex app that uses BrowserManager can pick off parameters from the URL

              to the HTML wrapper.  It can then add code to the wrapper that can be called

              from ExternalInterface to write HTML to the wrapper.

              • 4. Re: How do I replace the SWF?
                Jerry62712 Level 1

                When last I worked on this (October), I thought I had accessed the parameter from the wrapper, but when I started it again this time that wouldn't work for some unknown reason.  The Flex person only briefly tried this and then switched to going after the SWF file.

                 

                Now she said that Flex can't output a XML stream instead of the SWF file so I have to go with either LiveCycle or a java servlet.

                • 5. Re: How do I replace the SWF?
                  Flex harUI Adobe Employee

                  Who is the person(s) you are working with in Support?

                   

                  I would think you can use ExternalInterface to write XML to the HTML

                  wrapper.

                  • 6. Re: How do I replace the SWF?
                    Jerry62712 Level 1

                    That was my hope that I could just send a javascript command to hide the swf and write the XLM stream.  Anju Singh said I had to go with the SWF and not the wrapper because we had to accept a parameter and that couldn't be done if you used the wrapper.

                     

                    We are a pretty large shop and sent about 50 people to the Flex class.  We have also a large investment in LiveCycle as our TAM can attest to.  But not many have gone to this level on Flex here and I’m pretty much on my own.  Sigh.

                    • 7. Re: How do I replace the SWF?
                      Flex harUI Adobe Employee

                      If you've "paid" for a TAM, you should be using the TAM and your support

                      contact like Anju to push this issue to conclusion.  There is a standard

                      escalation process where critical issues get pushed up the chain until they

                      reach engineering.  If what you want to do is critical to your success,

                      request that Anju escalate the issue, and don't take no for an answer.

                      • 8. Re: How do I replace the SWF?
                        Jerry62712 Level 1

                        The problem is our TAM is with LiveCycle, not Flex.

                        • 9. Re: How do I replace the SWF?
                          Flex harUI Adobe Employee

                          I'm not sure that should matter.  Your company paid big bucks for a TAM.

                          Anyway, try Anju first and see if she'll escalate the issue.

                          • 10. Re: How do I replace the SWF?
                            Jerry62712 Level 1

                            She did bring in a guy in Boston that I talked with yesterday.  This has been dragging on for two months not including the first time I brought it up in September.  It got put on hold for a while and now my management is breathing down my neck to get results.  I can't fault them for that, they are right.  The payoff is getting the job done, not having excuses for not getting it done.

                             

                            Naturally, Kurt had ideas on how to do thing better, but there is no time to rewrite it again at this point.  I think he understands that and will help as much as he can.  Meanwhile, I'll try to get help wherever I can in case someone comes up with either a solution to the three different ways I see how to do it or a new way.

                             

                            BTW, those ways are 1) get a flex wrapper to hold a javascript that will a) when called remove the swf file from the browser and b) replace it with an XML stream, 2) get a LiveCycle wrapper to do that or 3) get a java solution that can do that.

                             

                            Way back when I thought we had the flex wrapper working, at least as far as accepting the XML parameter on the URL.  I'm not sure what happened there.  Perhaps it is the problem I recently discovered that Flex gags when you include this at the start of the XML:

                             

                            %3c%3fxml%20version%3d%221.0%22%20encoding%3d%22UTF-8%22%20%3f%3e or escaped

                            <?xml version="1.0" encoding="UTF-8" ?> (tried with both " and ')

                             

                            Eliminate that from the XML and Flex can read the parameter and process it correctly.

                             

                            Anyway, if you have any ideas I'm on this 100% of my time and have no problem coming in off shift to work on it if someone's timeframe demands it.

                            • 11. Re: How do I replace the SWF?
                              Jerry62712 Level 1

                              Sorry this is out of the flow, but I missed it before.

                               

                              How do I find out if I have BrowserManager working correctly?

                               

                              When I put this in:

                                          bm = BrowserManager.getInstance();
                              //            URLUtil.getFullURL(rootURL:String);
                              //            URLUtil.getFullURL(url:Sting);
                              //            trace("**Testing FSCalc L58 rootURL:" + rootURL);
                              //            trace("**Testing FSCalc L59 rootURL:" + url);
                                          trace("**Testing FSCalc L60 bm.url:" + bm.url);

                              bm.url is null.

                               

                              The full URL is:

                              http://localhost:8080/FSCalcFlexNew/FSCalc.html?xml=%3cFSParm%3e%3cHouseholdSize%3e03%3c%2 fHouseholdSize%3e%3cQualifyingMember%3e%3c%2fQualifyingMember%3e%3cGrossMonthlyEarnedIncom e%3e0200%3c%2fGrossMonthlyEarnedIncome%3e%3cGrossMonthlyOtherIncome%3e200%3c%2fGrossMonthl yOtherIncome%3e%3cTotalAssets%3e999%3c%2fTotalAssets%3e%3cDependentCareCostsAmt%3e500%3c%2 fDependentCareCostsAmt%3e%3cCourtOrderedSupportAmt%3e300%3c%2fCourtOrderedSupportAmt%3e%3c MedicalExpenseAmt%3e250%3c%2fMedicalExpenseAmt%3e%3cMonthlyRentOrMortgageAmt%3e250%3c%2fMo nthlyRentOrMortgageAmt%3e%3cMonthlyInsuranceAndTaxAmt%3e0%3c%2fMonthlyInsuranceAndTaxAmt%3 e%3cUtilityType%3eBilled%20for%20AC%2fHeat%3c%2fUtilityType%3e%3c%2fFSParm%3e   
                              according to the stack.

                               

                              What I wanted to see was xml=...

                              • 12. Re: How do I replace the SWF?
                                Flex harUI Adobe Employee

                                In Flex 3, you choose the HTML templates that support browser integration,

                                then add BrowserManager to your application.  There are some examples out

                                there to copy from.

                                • 13. Re: How do I replace the SWF?
                                  Flex harUI Adobe Employee

                                  Do you have a simple test case that attempts to do what you want?  It should

                                  not have require any server requests to run.  Maybe you put params on the

                                  url, you show them in the app so you know the parameter input is working,

                                  then press a button and the app disappears and the code attempts to replace

                                  the SWF by XML.

                                   

                                  Anju is level 2 support and should have a test case like that so we all

                                  understand what you are trying to accomplish.  It should then get escalated

                                  to Kurt in level 3 and if he can't solve it, it will get escalated to me.

                                   

                                  You need to go through them so it is all tracked, but I will see it soon if

                                  you are pushing hard enough.  If you have an incident number, please send it

                                  to my email directly.

                                  • 14. Re: How do I replace the SWF?
                                    Jerry62712 Level 1

                                    Thanks for the info.  I wanted to give them, at least Kurt, a chance to review the things I've done and found and emailed to him yesterday.  At least until this afternoon .  Anju was able to get the parameter if I came in using the SWF, but that will preclude me from using the wrapper to swap the output.

                                     

                                    When I added the BrowserManager per the doc ("http://livedocs.adobe.com/flex/3/html/help.html?content=deep_linking_3.html") and came up with this:

                                              private var bm:IBrowserManager;

                                     

                                              public function getTIERURL(e:Event):void {

                                                   bm = BrowserManager.getInstance();

                                                   trace("**Testing FSCalc L61 bm.url:" + bm.base);

                                                   trace("**Testing FSCalc L62 bm.url:" + bm.fragment);

                                                   trace("**Testing FSCalc L63 bm.url:" + bm.url);

                                     

                                    All were either null of "".  Sigh.

                                    • 15. Re: How do I replace the SWF?
                                      Jerry62712 Level 1

                                      Just an FYI (Case  #0181520884: Javascript write of Flex variable).

                                       

                                      I found a way to get the parameter off the URL with a wrapper being used.  I also can write something to the browser.  Here is how I did it in case anyone might need the technique (and I passed it on to Kurt and Anju):

                                          var locationURL:String = ExternalInterface.call( "function getFullURL(){ return location.href; }" );
                                          var startParm:int = locationURL.indexOf("=");
                                          var locationParm:String = locationURL.substr(startParm+1,locationURL.length);
                                      trace("\n**Testing location FSCalc L 61 URL:\n" + locationURL);
                                      trace("\nlocation Parm:\n" + locationParm);
                                      trace("\nStart Parm: " + startParm);

                                       

                                      I have to find out how to convert the string to an object or XML one so the following will work:

                                          var obj:Object = Application.application.parameters;
                                          for (var item:String in obj) {
                                              if (!(obj[item] == "true" || obj[item] == "false"))
                                                  xmlString = obj[item].toString();
                                          }

                                       

                                          // people access won't have any value - only TIER access
                                          if (xmlString != null)
                                              getXMLURL();

                                      At the back end is this:

                                      var outResults:String = "function writeString() { document.write('test data'); }";
                                      ExternalInterface.call(outResults);

                                      When I put in literals like this it works, that is all I see on the screen is the literal and no SWF.  I'll have to work to find a way to change the literals for a variable perhaps.

                                      • 16. Re: How do I replace the SWF?
                                        Flex harUI Adobe Employee

                                        The examples should have guided you to make an init call before accessing

                                        properties

                                        • 17. Re: How do I replace the SWF?
                                          Jerry62712 Level 1

                                          Yes, you are correct.  I had skipped that as it looked like it might be related to the event listener and in my case I don't need that.

                                           

                                          Putting in an ".init" resulted in the "base" and the "url" properties being filled in.  So I changed the input from xxx.yyy.zzz?www=vvvv to xxx.yyy.zzz#www and the "www" appeared in the fragment.  The problem is "www" represents an XML stream and BrowserManager seems to be going to a value pair.  My XML stream has about 12 nodes in it so I"m not sure it is practical to go with BrowserManager.

                                           

                                          Especially when the ExternalInterface will get the parm using javascript.  But that has problems as well.  One, the input is encoded so I'll have to decode it.  Two, the input is a stream and I need to get to the nodes which makes me think it has to be an object of the type of XML.  Does that sound right?

                                          • 18. Re: How do I replace the SWF?
                                            Flex harUI Adobe Employee

                                            I'm not sure what you mean by stream.

                                            • 19. Re: How do I replace the SWF?
                                              Jerry62712 Level 1

                                              Sorry for being inarticulate.

                                               

                                              "Stream" in this case means the URL parm as opposed to a physical file somewhere.

                                               

                                              I'm about 85% done now.  I get the output on the screen as an xml output.  But there are characters that I can't escape and at least on that is converted to the encoded value ("/" is changed somewhere to "%2f").  I had to modify the input because some magic character was killing me.  The input parm began with a header ("<?xml%20version="1.0" encoding="UTF-8" ?>") that in debug showed as either "<&xml"... when looked at in the value window, but if you put the mouse over it it became "<xml"...  I can't find a combination that will keep the input (see above)  with the question marks.

                                               

                                              What is the escape code for replacements?  Is that what was missing?  I tried "//", "/" and "\/" in the replacement, but none of them could convert a forward slash to anything else.  Can you convert multiple characters?  I tried "%2f" to be "/" and that didn't work either.

                                              • 20. Re: How do I replace the SWF?
                                                Flex harUI Adobe Employee

                                                Are you calling encodeURIComponent before passing the XML up through

                                                ExternalInterface and calling the equivalent decoding method from Javascript

                                                on the other side?

                                                • 21. Re: How do I replace the SWF?
                                                  Jerry62712 Level 1

                                                  I didn't call it on the upside, but I called decodeURI on the down side.  I've been told that doesn't do the job entirely and I believe that as I've seen it.  I'll switch to the decodeURIComponent and do the same on the upside.  I can see the data in the browser without the encoding ("<" and not "%3c").

                                                   

                                                  The only problem with that is I have to stop the browser.  How can I stop the application which should have the same effect?

                                                  • 22. Re: How do I replace the SWF?
                                                    Flex harUI Adobe Employee

                                                    I'm not clear what you mean by "stop the browser" and how that relates to

                                                    this issue. Decoding and encoding are pretty fast.

                                                    • 23. Re: How do I replace the SWF?
                                                      Jerry62712 Level 1

                                                      I'm actually talking about Flex.  After I write the data to the screen, the browser displays it as expected in IE.  This is always cause for alarm as IE isn't a very well behaved browser.  In FF the data is displayed on the screen, but you can see the activity indicator still going in FF.  If you manually hit the stop button (the big X), the data including the full xml appear if you do a source check.

                                                       

                                                      I expect the connection to Flex and the browser is still active after I do the ExternalInterface write to the screen with a document.write(...).  I think I need to either stop Flex or send something that will indicate to the browser that it's not getting anything else and to fully process what it has.

                                                      • 24. Re: How do I replace the SWF?
                                                        Flex harUI Adobe Employee

                                                        Every browser is different.  It may be that you have to write different

                                                        stuff for different browsers.