2 Replies Latest reply on Jul 17, 2009 3:10 AM by IrishAIRMax

    JavaScript libraries and Google JavaScript Library use within AIR?

    IrishAIRMax

      Hey everyone,

       

      As far as I have read, JavaScript libraries had to alter themselves for use within AIR e.g jQuery, mootools, dojo etc.. I don't know how they had to alter themselves but I can remember reading it somewhere.

       

      Now I am doing a project using the google API and I wated to use AIR, but the google documentation said that it only supports JavaScript client applications that run in a web page in a browser:

       

      • Firefox 2.x & 3.x
      • Internet Explorer 6 & 7
      • Safari 3.x
      • Google Chrome

       

       

      I know that this excludes AIR, but is it simply a case that google didn't think of AIR and it will still work......

       

      or..........

       

      AIR JavaScript is severally different to the types of JavaScript in these browsers, and the Google JavaScript library just won't work with AIR

      ???????

       

      Thank you all in advance, any help with this would be GREATLY appreciated!!!!!!!!!!

      IrishAIRMax

        • 1. Re: JavaScript libraries and Google JavaScript Library use within AIR?
          jbenson@oper8 Level 2

          The changes most js frameworkds had to undertake to support AIR involved primarily releasing memory and not creating additional memory leaks for AIR applications.

           

          The two main limitations I've encountered while using 3rd party Javascript APIs is that you cannot use eval in AIR and you must place non application code (ie code that is loaded from the internet) into a sandbox.

           

          For more information on AIR and javascript see:

          http://help.adobe.com/en_US/AIR/1.5/devappshtml/WS5b3ccc516d4fbf351e63e3d118666ade46-7fa7. html

           

          On AIR and application sandboxes see:

          http://help.adobe.com/en_US/AIR/1.5/devappshtml/WS5b3ccc516d4fbf351e63e3d118666ade46-7fa3. html

           

          The reason I bring up eval is that a lot of code is compressed using packer or other obfuscation / compression tools, many of which require eval to unobfuscate on load.   This can and will fail in AIR.  Code that is "minned" (whitespace removed) will work fine.

           

          Good luck!

          1 person found this helpful
          • 2. Re: JavaScript libraries and Google JavaScript Library use within AIR?
            IrishAIRMax Level 1

            Thank you for your reply Jason,

             

            I don't quiet know what you mean by, 'The changes most js frameworkds had to undertake to support AIR, involved primarily releasing memory and not creating additional memory leaks for AIR applications'

             

            Does this mean they had to release data when the data was received from the server by the client by putting it in a sandbox? And is the memory leaks, is that relating to how JavaScript is not too secure with it tranferral of memory, and something requests get lost?

             

            I am new to JavaScript and this is my first experience. It would be a GREAT help if you could tell me in your opinion if a block of code such as this below would run in AIR?

             

             

            /* 
             * Retrieve a list of blog posts
             */
            
            // Create the blogger service object
            var bloggerService = new google.gdata.blogger.BloggerService('GoogleInc-jsguide-1.0');
            
            // The feed URI ued to retrieve a list of blogs for a particular logged-in user
            var feedUri = 'http://www.blogger.com/feeds/default/blogs';
            
            // The callback method invoked when getBlogFeed() returns the list of our blogs
            var handleBlogFeed = function(blogFeedRoot) {
              var blogEntries = blogFeedRoot.feed.getEntries();
            
              // Get list of posts for each blog
              for (var i = 0, blogEntry; blogEntry = blogEntries[i]; i++) {
                var postsFeedUri = blogEntry.getEntryPostLink().getHref();
                var query = new google.gdata.blogger.BlogPostQuery(postsFeedUri);
            
                // Set the maximum number of blog posts to return
                query.setMaxResults(25);
                
                bloggerService.getBlogPostFeed(query, handleBlogPostFeed, handleError);
              }
            };
            
            // A callback method invoked getBlogPostFeed() returns data
            var handleBlogPostFeed = function(postsFeedRoot) {
              var posts = postsFeedRoot.feed.getEntries();
              
              // Display blog's title
              PRINT('Blog title: ' + postsFeedRoot.feed.getTitle().getText());
              
              for (var i = 0, post; post = posts[i]; i++) {
                var postTitle = post.getTitle().getText();
                var postURL = post.getHtmlLink().getHref();
             
                PRINT('post: <b><a href="' + postURL + '" target="_blank">' + postTitle + '</a></b>');
              }
              PRINT('');
            };
            
            var handleError = function(error) {
              alert(error);
            };
            
            bloggerService.getBlogFeed(feedUri, handleBlogFeed, handleError);

             

             

             

            Thank you SO MUCH for your help in advance! THANK YOU!!!!

             

            IrishAIRMax