Skip navigation
cdsvvxv
Currently Being Moderated

Bug in FlexGlobals.topLevelApplication?

Aug 28, 2012 5:50 AM

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>

 
Replies
  • Currently Being Moderated
    Aug 28, 2012 8:32 AM   in reply to cdsvvxv

    Are you saying the Alert.show is displaying something different on IE?

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 28, 2012 10:49 AM   in reply to cdsvvxv

    Which version of IE?  Can you make the test SWF and HTML wrapper publicly available?

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 28, 2012 4:38 PM   in reply to cdsvvxv

    And which version of IE are you using?

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 28, 2012 11:47 PM   in reply to cdsvvxv

    Sorry, wasn’t clear.  I don’t want a zip file, I want a URL hosting the test app.

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 29, 2012 12:10 PM   in reply to cdsvvxv

    Interesting.  I’d never come across that before.  I noticed you are relying on object to string conversion (the toString() method).  You might have better luck using FlexGlobals.topLevelApplication.name

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 31, 2012 7:55 AM   in reply to cdsvvxv

    I’m not sure what your goal is.  FlexGlobals.topLevelApplication is correctly returning the Main class instance in all browsers.  It is only the toString() implied in your Alert test that displays something different on IE.  If you need to access any other properties on the application, they will be there in all browsers.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points