12 Replies Latest reply: Aug 31, 2012 8:31 AM by cdsvvxv RSS

    Bug in FlexGlobals.topLevelApplication?

    cdsvvxv

      I am having a problem with the FlexGlobals.topLevelApplication. I have five situations:

       

      1) Running in the prjector;

      2) Firefox, running the swf directly in the browser;

      3) Firefox, running with the swf embedded in a HTML page;

      4) IE, running the swf directly in the browser;

      5) IE, running with the swf embedded in a HTML page.

       

      The following are the returns of the FlexGlobals.topLevelApplication command:

       

      1) Main0;

      2) Main0;

      3) Main0;

      4) Main0;

      5) flexglobals.

       

      The last one looks very, very wrong to me, and it means that I can't get the topLevelApplication in IE when the SWF is embedded in a HTML page (the most common scenerio!). Instead I get either:

       

      1) The value of attributes.id;

      2) or if that is not specified, the id of the HTML div that the SWF is enclosed in, which in this case is 'altContent'.

       

      I have tried on 3 different machines all running Windows 7 with the following player versions:

       

      11.4.402.265

      11.3.300.265

      11.3.300.271

       

      As Application.application is now depreciated and I can't even compile with that at the moment, is there another reliable way to get the topLevelApplication? My application is failing in IE and it seems to be due to the FlexGlobals.topLevelApplication.

       

      The code is using SWFObject which I haven't included.

       

      -- Main.mxml ---

       

      <?xml version="1.0" encoding="utf-8"?>

      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"

                     xmlns:s="library://ns.adobe.com/flex/spark"

                     xmlns:mx="library://ns.adobe.com/flex/mx"

                     creationComplete="onCreationComplete()">

       

          <fx:Script>

              <![CDATA[

                  import mx.controls.Alert;

                  import mx.core.FlexGlobals;

       

                  private function onCreationComplete():void {

                      Alert.show("FlexGlobals.topLevelApplication [" + FlexGlobals.topLevelApplication + "]");

                  }

              ]]>

          </fx:Script>

       

      </s:Application>

       

      --- index.html ---

       

      <!DOCTYPE html>

      <html lang="en">

      <head>

          <meta charset="utf-8"/>

          <title>flexglobals</title>

          <meta name="description" content="" />

       

          <script src="js/swfobject.js"></script>

          <script>

              var flashvars = {

              };

              var params = {

                  menu: "false",

                  scale: "noScale",

                  allowFullscreen: "true",

                  allowScriptAccess: "always",

                  bgcolor: "",

                  wmode: "direct" // can cause issues with FP settings & webcam

              };

              var attributes = {

                  id:"flexglobals"

              };

              swfobject.embedSWF(

                  "flexglobals.swf",

                  "altContent", "100%", "100%", "10.0.0",

                  "expressInstall.swf",

                  flashvars, params, attributes);

          </script>

          <style>

              html, body { height:100%; overflow:hidden; }

              body { margin:0; }

          </style>

      </head>

      <body>

          <div id="altContent">

              <h1>flexglobals</h1>

              <p><a href="http://www.adobe.com/go/getflashplayer">Get Adobe Flash player</a></p>

          </div>

      </body>

      </html>