5 Replies Latest reply on Apr 26, 2013 3:59 AM by andreglud

    navigateToURL Issues...

    andreglud

      Hello Fellow Humans Around The World Of Earth!

       

       

      Before I start I wanna make sure everyone knows, that I'm new to Flash. I'm trying to learn it myself but with a little help from a friend.

       

       

      Anyway, I'm trying to develop an application for the Android Market for my clan. It should be able to show up a specific url. I have found out that I should use a "command" called navigateToURL.

       

       

      This is what one of my friends has made but it doesn't seem to work.

       

       

      [QUOTE]

      <s:ViewNavigator label="Forum" width="100%" height="100%" firstView="views.ForumView" click="openWebsite()"/>

       

       

      <fx:Script>

                <![CDATA[

                          import flash.net.navigateToURL;

                          protected function openWebsite () : void

                          {

                                    navigateToURL(new URLRequest("www.goodgamingpeople.com@url"), "_self");

                          }

                ]]>

      </fx:Script>

      [/QUOTE]

       

       

      I want it to show a website inside the app and not like a pop-up into the person's device's web browser.

       

       

      If anyone of you have any other idea how to do this, or know what is wrong I would be more than happy to know it! Remember to keep your language clean!

        • 1. Re: navigateToURL Issues...
          soul-mapp

          You have to use StageWebView, if you want the browse the web within your mobile app,

          Here is quick example..

           

          <?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="title whatever"

                  viewActivate="init()">

             

              <fx:Script>

                  <![CDATA[

                      import spark.events.ViewNavigatorEvent;

                      protected var webView:StageWebView = new StageWebView();

                     

                      protected function init():void

                      {

                          webView.stage = stage;

                          webView.viewPort = new Rectangle(0, 0, SETWIDTH, SETHEIGHT);

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

                          addEventListener(ViewNavigatorEvent.REMOVING, onRemove);

                      }

                     

                      protected function onRemove(event:ViewNavigatorEvent):void

                      {

                          this.webView.dispose();

                      }

                     

                      protected function BackBtn_clickHandler(event:MouseEvent):void

                      {

                          // TODO Auto-generated method stub

                          if (webView.isHistoryBackEnabled)

                          {

                              webView.historyBack();

                          }

                          else

                          {

                              trace("No pages in the browsing history.")

                          }

                      }

                     

                      protected function ForwardBtn_clickHandler(event:MouseEvent):void

                      {

                          // TODO Auto-generated method stub

                          if (webView.isHistoryForwardEnabled)

                          {

                              webView.historyBack();

                          }

                          else

                          {

                              trace("No pages in the browsing history.")

                          }

                      }

                     

                  ]]>

              </fx:Script>

              <fx:Declarations>

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

              </fx:Declarations>

           

          then ofcourse connect your buttons here..

          </s:View>

           

          Otherwise the correct code to use for the navigateToURL is.

          <fx:Script>

                    <![CDATA[

                              import flash.net.navigateToURL;

                              protected function openWebsite () : void

                              {

                                        navigateToURL(new URLRequest('http://www.goodgamingpeople.com"));

                              }

                    ]]>

          </fx:Script>

          • 2. Re: navigateToURL Issues...
            andreglud Level 1

            Hmm... it dosen't quit seem to be working. http://www.mediafire.com/download.php?3pjbpocw8rs3w2u

            • 3. Re: navigateToURL Issues...
              soul-mapp Level 1

              send me a zip. not fxp

              im getting a error when i try to import it

               

              WAIT JUST GOT IT OPENED

               

              Message was edited by: soul-mapp

              • 4. Re: navigateToURL Issues...
                soul-mapp Level 1

                Ok.. the example i gave above was only a example

                there were parts you need to add and change..
                Anyway..try this..

                 

                <?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="Server Status">

                    <fx:Declarations>

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

                    </fx:Declarations>

                    <fx:Script>

                        <![CDATA[

                            import spark.events.ViewNavigatorEvent;

                            protected var webView:StageWebView = new StageWebView();

                           

                            protected function init():void

                            {

                                webView.stage = stage;

                                webView.viewPort = new Rectangle(0, 20, stage.stageWidth, stage.stageHeight);

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

                                addEventListener(ViewNavigatorEvent.REMOVING, onRemove);

                            }

                           

                            protected function onRemove(event:ViewNavigatorEvent):void

                            {

                                this.webView.dispose();

                            }

                           

                            protected function BackBtn_clickHandler(event:MouseEvent):void

                            {

                                    // TODO Auto-generated method stub

                                    if (webView.isHistoryBackEnabled)

                             {

                                webView.historyBack();

                             }

                             else

                             {

                               trace("No pages in the browsing history.")

                             }

                            }

                                       

                            protected function ForwardBtn_clickHandler(event:MouseEvent):void

                            {

                                // TODO Auto-generated method stub

                                if (webView.isHistoryForwardEnabled)

                             {

                                webView.historyBack();

                             }

                             else

                             {

                               trace("No pages in the browsing history.")

                             }

                            }

                           

                        ]]>

                    </fx:Script>

                   

                            <s:Button click="BackBtn_clickHandler(event)" label="back"

                                         y="7" left="475" />

                              

                               <s:Button click="ForwardBtn_clickHandler(event)" label="Forward"

                              y="7" left="556" />

                </s:View>

                • 5. Re: navigateToURL Issues...
                  andreglud Level 1

                  Hmm... it still doesn't seem to be working. Or maybe its just the Adobe Air Simulator that can't show it?