2 Replies Latest reply on Dec 3, 2009 6:42 PM by jayuzzz

    Passing Variable to air app when launch using Badger

    jayuzzz

      Hi all,

      I am going to desperately to develop my application. Hope someone can help me........

       

      I am using badger for air which I get it here http://www.adobe.com/devnet/air/articles/badger_for_air_apps.html and it launch my app correctly, but I can't pass any variable into my app when launch.

      I have read the instruction and adding some code like this :

       

      on index.html(show my badge installer):

          var so = new SWFObject("AIRInstallBadge.swf", "", "215", "180", "9.0.115", "#000000");

       

              so.addVariable("airversion", "1.5");

       

              so.addVariable("appname", "Secure%205");

       

              so.addVariable("appurl", "http://localhost/testing/source/secure5.air");

       

              so.addVariable("appid", "examples.html.HelloWorld");

       

              so.addVariable("pubid", "B71ED76ECC937067D72BB9A0CDB516D1A8F43A9E.1");
             
              so.addVariable("arguments", "launch from browser");// this is my code

       

              so.addVariable("appversion", "0.1");

       

              so.write("flashcontent");

       

      on index.html(my initial content) :

      var urlMonitor;
      var urlReq;
      var invokeEvent;
      var applicationID = "myappid";
      var publisherID = "mypubid";
      var applauncarg;
      //var admin="admin";
      function doWindow()
      {
      var options = new air.NativeWindowInitOptions();
      options.transparent = false;
      options.systemChrome = air.NativeWindowSystemChrome.STANDARD;
      options.minimizable = false;
      options.maximizable = false;
      options.resizable=false;
      var windowBounds = new air.Rectangle(0,0,air.Capabilities.screenResolutionX,air.Capabilities.screenResolutionY);
      var urlreq="http://www.example.com";
      var newHTMLLoader = air.HTMLLoader.createRootWindow(true, options, true, windowBounds);
      newHTMLLoader.load(new air.URLRequest(applauncharg));
      newHTMLLoader.stage.nativeWindow.alwaysInFront = true;
      newHTMLLoader.stage.nativeWindow.addEventListener(air.NativeWindowBoundsEvent.MOVE,handlem ove);
      newHTMLLoader.stage.nativeWindow.addEventListener(air.Event.CLOSE,onCloseCommand);
      urlMonitor = new air.URLMonitor(new air.URLRequest("http://www.example.com"));
      urlMonitor.addEventListener(air.StatusEvent.STATUS, onStatusChange);
      urlMonitor.start();
      air.NativeApplication.nativeApplication.addEventListener(air.InvokeEvent.INVOKE, onInvoke);
      //urlReq=new air.URLRequestDefaults.manageCookies = true;

       

      function handlemove()
      {
      newHTMLLoader.stage.nativeWindow.x=0;
      newHTMLLoader.stage.nativeWindow.y=0;
      }

       


      function onCloseCommand(exitingEvent) {
      var winClosingEvent;
      for (var i = 0; i < air.NativeApplication.nativeApplication.openedWindows.length; i++) {
      var win = air.NativeApplication.nativeApplication.openedWindows[i];
      winClosingEvent = new air.Event(air.Event.CLOSING,false,true);
      win.dispatchEvent(winClosingEvent);
      if (!winClosingEvent.isDefaultPrevented()) {
      win.close();
      } else {
      exitingEvent.preventDefault();
      }
      }
      if (!exitingEvent.isDefaultPrevented()) {
      //perform cleanup
      }
      }

       

      }

       

      function onInvoke(e)
      {
      //apparg=event.applauncharg.toString();
      //alert ('oK'+apparg);
      applauncarg = event.arguments;
      air.trace("onInvoke : " + event.applauncharg);
      //air.Introspector.Console.log( applauncarg );
      alert (applauncarg);
      }

        • 1. Re: Passing Variable to air app when launch using Badger
          jayuzzz Level 1

          sory, there is mistake here......

          the question isn't finish yet.

          function onInvoke(e)
          {

          //my code
          applauncarg = event.arguments;
          air.trace("onInvoke : " + event.applauncharg);
          alert (applauncarg);//just to make sure the variable had been sent correctly

          }

           

          My application running smoothly but there is no alert that show applauncharg variable.

          then I am trying to know if invoke event run correctly or not by adding code

          alert ("OK");

          and it works, so there is no problem with the event listener.

          does any one know if I missing something or any thing wrong with my code?

           

          sory, there is mistake here......

          the question isn't finish yet.

          function onInvoke(e)
          {

          //my code
          applauncarg = event.arguments;
          air.trace("onInvoke : " + event.applauncharg);
          alert (applauncarg);//just to make sure the variable had been sent correctly

          }

           

          I have get the answer. If someone need the source code, just Pm me and I'll give you my Source to help you.

          The first is to make sure that your action scipt code can handle the argument that passed by javascript.

          Make attention between invoke event and browser invoke event! it is almost same but they are different.

          If you type browser invoke event, it seems browser invokeevent doesn't recognized, but it works.

          The second is my mistake on source code. onInvokeevent shold be like this :

          function onInvoke(e)
          {

          //my code
          applauncarg = .arguments;
          alert (applauncarg);

          }

          -closed-

          • 2. Re: Passing Variable to air app when launch using Badger
            jayuzzz Level 1

            I have get the answer. If someone need the source code, just Pm me and I'll give you my Source to help you.

             

            The first is to make sure that your action scipt code can handle the argument that passed by java script.

             

            Make attention between invoke event and browser invoke event! it is almost same but they are different.

             

            If you type browser invoke event, it seems browser invoke event doesn't recognized, but it works.

             

            The second is my mistake on source code. onInvokeevent shold be like this :

             

            function onInvoke(e)

            {

             

            //my code

            applauncarg = e.arguments;

            alert (applauncarg);

            }

             

            -closed-