Flex Air HTMLLoader blank pop up window when flash

2019-04-15 15:39发布

问题:

I have a flex Air program that loads external content with the HTMLLoader. Now for some reason whenever I load a page that has any flash content a blank system window pops up outside of my program. It's completely blank, all white with min, max and close buttons. If I close it any flash content I loaded stops working. For the life of my I can't figure out what's happening and there's no messages in the console and no title for the window.

Does anyone have any ideas? I appreciate any help you can give. Here's the code I'm using:

private var webPage:HTMLLoader;


private function registerEvents():void
{
    this.addEventListener(gameLoadEvent.GAME_LOAD, gameLoad);
    //webPage = new HTMLLoader();

}

//function called back from Game Command to load correct game
private function gameLoad(event:Event):void
{
    var gameEvent:gameLoadEvent = event as gameLoadEvent;
    loadgame(gameEvent.url, gameEvent.variables);

}


private function loadgame(url:String, variableString:String):void
{
    DesktopModelLocator.getInstance().scaleX = 1;
    DesktopModelLocator.getInstance().scaleY = 1;

    //var url:String = "http://pro-us.sbt-corp.com/aspx/member/LaunchGame.aspx";
    var request:URLRequest = new URLRequest(url);
    //var variables:URLVariables = new URLVariables("gameNum=17&as=as1&t=demo&package=a&btnQuit=0");

  if(variableString != null && variableString != ""){
    var variables:URLVariables = new URLVariables(variableString);
    variables.exampleSessionId = new Date().getTime();
    variables.exampleUserLabel = "guest";
    request.data = variables;
  }

    webPage = HTMLLoader.createRootWindow(true, null, true, null);
    webPage.height = systemManager.stage.nativeWindow.height - 66;
    webPage.width = systemManager.stage.nativeWindow.width;
    webPage.load(request);
    webPage.navigateInSystemBrowser = false;

    flexBrowser.addChild(webPage);      
}

]]>
</mx:Script>


<mx:HTML id="flexBrowser" width="1366" height="658" backgroundAlpha="0.45" creationComplete="registerEvents();" x="0" y="0">
</mx:HTML>  

回答1:

you're not using any of the capabilities of your html component. As is, it may as well be a canvas since all you're doing is addChild to flexBrowser, a DisplayObjectContainer. Though I wouldn't do it this way, you can pretty simply set the flexBrowser.htmlLoader.load(request); and get rid of all that webPage stuff.



回答2:

Is your application using a transparent window? air won't display flash content in the HTMLLoader in that case, see http://bugs.adobe.com/jira/browse/SDK-15033

One workaround is to use http://code.google.com/p/adobe-air-util/source/browse/trunk/src/net/tw/util/air/HTMLOverlay.as.

I had to do some changes to get it to work well with our app. I sent an email to the project owner to contribute the changes, if you are still on it I can send you the patch. The most important change, is that the html overlay window does go behind other apps when switching i.e. alt-tab or opening another app.

Update: I committed the changes to the overlay above, check it out as it should work for you as well. I know it seems like an awful workaround, but there doesn't seem to be anything better until adobe fixes the issue. If you do see something better, make sure to post the update :)



回答3:

This problem has been fixed in AIR 1.5.2:

Before AIR 1.5.2, SWF content embedded in and HTML container in a transparent window could not be displayed. With AIR 1.5.2, SWF content can be displayed with certain wmode settings.



标签: flex air popup