Allowing pop-up's and downloads with flex

Posted by ShadowVariable on Stack Overflow See other posts from Stack Overflow or by ShadowVariable
Published on 2013-10-17T21:51:33Z Indexed on 2013/10/17 21:53 UTC
Read the original article Hit count: 191

Filed under:
|
|

I'm building an flex app that is basically a wrapper for a few websites. One of them is a google docs website, and I'm trying to get flex to allow downloads or popups or something that will allow me to do it. I've tried a whole bunch of solutions online and none of them have worked out. Here's the code so far:

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
                       xmlns:s="library://ns.adobe.com/flex/spark"
                       xmlns:mx="library://ns.adobe.com/flex/mx"
                       width="100%" height="100%"
                        creationComplete="onCreationComplete()">

    <s:layout>
        <s:HorizontalLayout/>
    </s:layout>
    <fx:Style source="style.css"/>
    <fx:Script>
        <![CDATA[

            include "CustomHTMLLoader.as";

            private function onCreationComplete():void
            {
                // ... other stuff ...
                var custom:object;
                custom.htmlHost = new MyHTMLHost();
            }

        ]]>
    </fx:Script>
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <s:BorderContainer width="100%" height="100%" backgroundColor="#87BED0" styleName="container">
        <s:Panel x="188" y="17" width="826" height="112" borderAlpha="0.15" chromeColor="#0C5A74"
                 color="#FFFFFF" cornerRadius="20" dropShadowVisible="false" enabled="true"
                 title="Customer Service Control Panel">
            <s:controlBarContent/>

            <s:Button id="home" x="13" y="10" height="44" label="Phones"
                      click="myViewStack.selectedChild=Home;" enabled="true"
                      icon="@Embed('assets/iconmonstr-mobile-phone-6-icon-32.png')"/>
            <s:Button id="liveagent" x="131" y="10" height="44" label="Live Agent"
                      click="myViewStack.selectedChild=live_agent;"
                      icon="@Embed('assets/iconmonstr-speech-bubble-11-icon-32.png')"/>
            <s:Button id="bigcommerce" x="260" y="10" width="158" height="44" label="Big Commerce"
                      click="myViewStack.selectedChild=bigcommerce_home;"
                      icon="@Embed('assets/iconmonstr-coin-6-icon-48.png')"/>
            <s:Button id="faq" x="436" y="10" width="88" height="44" label="FAQ"
                      click="myViewStack.selectedChild=freqaskquestions;" fontFamily="Arial"
                      icon="@Embed('assets/iconmonstr-help-4-icon-32.png')"/>
            <s:Button id="call" x="540" y="10" width="131" height="44" label="Google Docs"
                      click="myViewStack.selectedChild=call_notes;"
                      icon="@Embed('assets/iconmonstr-text-file-4-icon-32.png')"/>
            <s:Button id="hoot" x="684" y="10" width="122" height="44" label="HootSuite"
                      click="myViewStack.selectedChild=hoot_suite;"
                      icon="@Embed('assets/iconmonstr-facebook-icon-32.png')"/>
        </s:Panel>
        <mx:ViewStack id="myViewStack" x="0" y="140" width="100%" height="100%" borderStyle="solid">
            <s:NavigatorContent id="Home">
                <s:BorderContainer width="100%" height="100%">
                    <mx:HTML x="0" y="0" width="100%" height="100%" borderVisible="false"
                             horizontalScrollPolicy="off"
                             location="http://mbvphone.mtbakervapor.org/vbx/messages/inbox"
                             />
                </s:BorderContainer>
            </s:NavigatorContent>
            <s:NavigatorContent id="bigcommerce_home">
                <s:BorderContainer width="100%" height="100%">
                <mx:HTML  x="0" y="0" width="100%" height="100%" borderVisible="false"
                         horizontalScrollPolicy="off"
                         location="http://www.mtbakervapor.com/admin"
                         />
                </s:BorderContainer>
            </s:NavigatorContent>
            <s:NavigatorContent id="live_agent">
                <s:BorderContainer width="100%" height="100%">
                    <mx:HTML x="0" y="0" width="100%" height="100%" borderVisible="false"
                             horizontalScrollPolicy="off"
                             location="http://mbvphone.mtbakervapor.org/liveagent/agent/#login"
                             />
                </s:BorderContainer>
            </s:NavigatorContent>
            <s:NavigatorContent id="freqaskquestions">
                <s:BorderContainer width="100%" height="100%">
                    <mx:HTML x="0" y="0" width="100%" height="100%" borderVisible="false"
                             horizontalScrollPolicy="off"
                             location="http://mbvphone.mtbakervapor.org/liveagent/"
                             />
                </s:BorderContainer>
            </s:NavigatorContent>
            <s:NavigatorContent id="call_notes">
                <s:BorderContainer width="100%" height="100%">
                    <mx:HTML id="html" x="0" y="0" width="100%" height="100%" borderVisible="false"
                             horizontalScrollPolicy="off"
                             location="https://drive.google.com/a/mtbakervapor.com/"
                             htmlHost="{new CustomHost()}"
                             />
                </s:BorderContainer>
            </s:NavigatorContent>
            <s:NavigatorContent id="hoot_suite">
                <s:BorderContainer width="100%" height="100%">
                    <mx:HTML x="0" y="0" width="100%" height="100%" borderVisible="false"
                             horizontalScrollPolicy="off"
                             location="https://hootsuite.com/login"
                             />
                </s:BorderContainer>
            </s:NavigatorContent>
        </mx:ViewStack>
        <s:Image x="0" y="0" width="180" height="140" scaleMode="letterbox" smooth="false"
                 source="assets/mbvlogo_black.png"/>
    </s:BorderContainer>
</s:WindowedApplication>

and the custom class code:

package 
{
    import flash.html.HTMLHost;
    import flash.html.HTMLWindowCreateOptions;
    import flash.html.HTMLLoader;

    public class MyHTMLHost extends HTMLHost
    {
        public function MyHTMLHost(defaultBehaviors:Boolean=true)
        {
            super(defaultBehaviors);
        }

        override public function createWindow(windowCreateOptions:HTMLWindowCreateOptions):HTMLLoader
        {
            // all JS calls and HREFs to open a new window should use the existing window
            return HTMLLoader.createRootWindow();
        }
    }
}

any help would be appreciated.

© Stack Overflow or respective owner

Related posts about flex

Related posts about actionscript