Thursday, March 15, 2007

Apollo Browser in five lines of code

In yesterday's post about what Apollo is, a comment appeared to challenge the notion of being able to implement a simple browser in 5 lines of code. Rather than rebuke it on the comments list, I decided to make this post and place the code here to show how easy it is. This is as simple as it gets, no back buttons, SSL, bookmarks etc, but it is a browser that you can type a URL into and it will navigate to the URL and display the HTML properly formatted.

The sample Apollo MXML code:

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

<!--line one. I am not goign to count the XML PI-->
<mx:ApolloApplication mx="" layout="vertical" cornerRadius="12">

<!-- line two -->
<mx:Text text="Enter URL and hit enter" fontFamily="Arial" fontSize="16" fontWeight="bold" />

<!-- line three-->
<mx:TextInput id="urlTxt" width="100%" enter="html.location=urlTxt.text;" text="" />

<!--line four -->
<mx:HTML id="html" width="100%" height="100%" location="">

<!--line five. Not really a line of code, just closing the root tag -->


Here is the screenshot of the Apollo browser application:


  1. Optimisation :

    mx:HTML could be done on one line not two... and this is HTML, so you can of course do it all on one line :)

  2. Yeah - I had it like this in Flex Builder but if you cut and paste MXML to blogger then do an "edit HTML" view and switch back to the preview, Blogger reformats the elements. I caught the others but not this one when I commented it.

  3. And of course you don't absolutely need the instructional text label... bringing the count down to 4. (You could always place the instructional text as a "prompt" text within the text input ... that is, text="Ener URL Here and select enter" click="urlTxt.text = ''")

  4. and some doubted it could be done.



  5. This comment has been removed by a blog administrator.


Do not spam this blog! Google and Yahoo DO NOT follow comment links for SEO. If you post an unrelated link advertising a company or service, you will be reported immediately for spam and your link deleted within 30 minutes. If you want to sponsor a post, please let us know by reaching out to duane dot nickull at gmail dot com.