3 Replies Latest reply on Jan 16, 2012 1:01 PM by Nelodroid

    StageWebView problem - while testing on emulator, it starts the browser on my desktop

    learningFlex5000

      This is my first test project. When executing the code, the emulator shows google page...but it also starts mozilla browser on my desktop...Is that normal?

       

       

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

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

                          title="HomeView" >

                <fx:Declarations>

                          <!-- Place non-visual elements (e.g., services, value objects) here -->

                </fx:Declarations>

                <!-- html.addEventListener(Event.COMPLETE, completeHandler); -->

                <fx:Script>

                          <![CDATA[

                                    //import flash.media.StageWebView;

                                    //import flash.net.URLRequest;

       

                                    protected var webView:StageWebView = new StageWebView();

       

       

                                    protected function view1_viewActivateHandler():void

                                    {

                                              if (StageWebView.isSupported)

                                              {

                                                        webView.viewPort = new Rectangle(5, 80, stage.width-10, stage.height-9);

                                                        webView.stage = this.stage;

                                                        //webView.addEventListener(LocationChangeEvent.LOCATION_CHANGE,o nURLChange);   

                                                        webView.loadURL("http://www.google.com");   

                                                        //addEventListener(ViewNavigatorEvent.REMOVING,onRemove);

                                              }

                                              else {

                                                        }   

                                    }

       

                                    protected function onURLChange(event:LocationChangeEvent):void

                                    {

                                              trace("URL change");

                                              // Uncomment the following line to load in the default browser instead...

                                              navigateToURL(new URLRequest(event.location));

                                       

                                    }

       

                                    protected function onRemove(event:ViewNavigatorEvent):void

                                    {

                                              this.webView.dispose();

                                    }

       

                                    protected function myHandler():void {

                                              view1_viewActivateHandler();

                                    }

                          ]]>

                </fx:Script>

                <s:navigationContent/>

       

                <s:layout>

                          <s:VerticalLayout gap="40" horizontalAlign="center" paddingBottom="5" paddingLeft="5"

                                                                    paddingRight="5" paddingTop="10" verticalAlign="top"/>

                </s:layout>

                <s:Button label="Show Web" click="myHandler()"/>

       

       

      </s:View>

        • 1. Re: StageWebView problem - while testing on emulator, it starts the browser on my desktop
          Gustavo Duenas

          not at all, something is wrong there, check the code. I did the same and it is only showing the browser on air, not the external browser

          • 2. Re: StageWebView problem - while testing on emulator, it starts the browser on my desktop
            learningFlex5000 Level 1

            Thanks for your answer. Will see if there is anything in my code that does this.

            • 3. Re: StageWebView problem - while testing on emulator, it starts the browser on my desktop
              Nelodroid

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

              <s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
                      xmlns:s="
              library://ns.adobe.com/flex/spark" title="HTML Content" viewActivate="view1_viewActivateHandler(event)">

               

                  <fx:Script>

                      <![CDATA[

                          import flash.media.StageWebView;

                          import flash.net.URLRequest;

                          import spark.events.ViewNavigatorEvent;

               

                          protected var webView:StageWebView = new StageWebView();

                          protected var openBrowser:Boolean = false;

               

               

                          protected function view1_viewActivateHandler(event:ViewNavigatorEvent):void

                          {

                              if (StageWebView.isSupported)

                              {

                                  currentState = "normal";

                                  webView.stage = stage;

                                  webView.viewPort = new Rectangle(20, 100, 450, 450);

                                  webView.addEventListener(LocationChangeEvent.LOCATION_CHANGE,onURLChange);   

                                  webView.loadURL("http://www.google.com");   

                                  addEventListener(ViewNavigatorEvent.REMOVING,onRemove);

                              }

                              else {

                                  currentState = "unsupported";

                                  lblSupport.text = "StageWebView feature not supported";

                              }   

                          }

               

                          protected function onURLChange(event:LocationChangeEvent):void

                          {

                              trace("URL change");

                              // Uncomment the following line to load in the default browser instead...
                              //navigateToURL(new URLRequest(event.location));

                          }

               

                          protected function onRemove(event:ViewNavigatorEvent):void

                          {

                              this.webView.dispose();

                          }

                      ]]>

                  </fx:Script>

               

                  <s:states>

                      <s:State name="normal"/>

                      <s:State name="unsupported"/>

                  </s:states>

               

                  <s:Label id="lblSupport" includeIn="unsupported" width="95%" horizontalCenter="0" verticalCenter="0"/>

               

              </s:View>

               

               

              May this code help you