9 Replies Latest reply on Feb 13, 2008 9:07 AM by roland.schroth

    Ebedded Flex app does not play automatically

    Keytree
      I have a flex app that is embedded in a web page.
      When the page loads for the first time the app does not run automatically but is in "loop" mode.
      In order to embed the application in the html page we have copied the html and javascript files that the Flex builder generates :
      AC_OETags.js, history.htm, history.js etc.

      This only happens the first time the page is loaded, subsequently it loads and plays automatically.
      I would be grateful is anyone has some insight here.
        • 1. Re: Ebedded Flex app does not play automatically
          gdoumenc Level 1
          I had the same issue because I used HTTPRequest and Tomcat.. Is-it the same case for you?
          • 2. Re: Ebedded Flex app does not play automatically
            jlingwai Level 1
            I think i'm missing the question???So the flex loads the first time you go to the html page.....and you don't want this to happen????? I also have an application where flex sends a httpRequest to the same page and doesn't reload the application. Is this what you want????

            -JoSh
            • 3. Re: Ebedded Flex app does not play automatically
              Keytree Level 1
              Just to be clear the app (movie) loads first time but does not play.
              This happens the very first time the user loads the page.
              You have to right click and select "Play"

              Any subsequent visit to the page it works fine and "plays" OK.

              I am using WebServices and the enenvironment is actually SAP Business Server Pages (think JSP)
              • 4. Re: Ebedded Flex app does not play automatically
                gdoumenc Level 1
                No, I just wanted to say that I had the same issue (doesn't start on load but on reload..) on a flex aplication with HTTPRequest and having tomcat as server.

                I have installed the data service (using specific flex servlet) and the issue has gone.... !!!!

                Don't ask me why but that's what I discover after 3 days of investigations...!!

                My 3 cents
                • 5. Re: Ebedded Flex app does not play automatically
                  Keytree Level 1
                  Thanks gdoumenc it is the same issue I think but I can't install the data service.
                  I'm sure I'll find plan B eventually...
                  • 6. Ebedded Flex app does not play automatically
                    PKarpenko
                    Hi, I'm having the same exact issue. Embedded Flex SWF loads but does not play on first load but does on subsequent loads.

                    The app is a basic Hello World with no http requests of any kind, just a big label in the middle.

                    I've even tried adding <param name="play" value="true"/> to the HTML wrapper with no results.

                    Have any of you found a solution to this issue?

                    (Btw, I'm using Flex Builder 3 Beta 3.)
                    • 7. Re: Ebedded Flex app does not play automatically
                      roland.schroth Level 1
                      Hi,

                      I am having the exact same problem.
                      Did you find a solution for this?

                      Any help would be greatly appreciated :-)
                      • 8. Re: Ebedded Flex app does not play automatically
                        Keytree Level 1
                        I did get to the bottom of this in the end by adding in some JavaScript called on the onload event of the page body:
                        It's a complete nonsense hack but does work for me.

                        function checkPlay(){
                        var movie=window.document.<swf id>
                        if (movie != undefined && !movie.IsPlaying() && movie.PercentLoaded()==100){
                        movie.Play();
                        movie.Forward();
                        }
                        }
                        • 9. Re: Ebedded Flex app does not play automatically
                          roland.schroth Level 1
                          Thanks for your answer, we found a similar workaround.

                          We did the following:
                          --------------------------------------
                          1) disable automatic starting of the SWF in the script that created the plugin by adding these parameters:
                          "play", "false",
                          "loop", "false",

                          2) adding some own javascript to the template-html:
                          var isMovieLoaded = false;
                          function setIsMovieLoaded(){
                          isMovieLoaded = true;
                          }

                          function start(id) {
                          var swf = document.getElementById(id);
                          if (swf) {
                          swf.Play();
                          }
                          }

                          function playMovie(){
                          if( !isMovieLoaded ){
                          start( "${application}" );
                          }
                          }

                          window.setTimeout("playMovie()", 3000);

                          3) calling setIsMovieLoaded() via ExternalInterface from the loaded application when initializing:
                          if (ExternalInterface.available)
                          {
                          ExternalInterface.call("setIsMovieLoaded");
                          }

                          --------------------------------------
                          This way when the application loads and plays correctly, the delayed call to playMovie in the html-template does nothing, because the flag isMovieLoaded was already set by the application.
                          If that is not the case, the movie is explicitly startet via the start function.

                          Thanky anyway :-)