Quality Reads

Sunday, May 06, 2007

Make Your Own Browser w/ Apollo

I had a couple minutes on Sunday to play around with Flex/Apollo. In less than an hour, I had this mini-browser working nicely. Check out the source code below for an example of databinding and the Apollo mx:HTML tag.



My blogger application is shaping up nicely. Expect to see the source code for that within a week or so. Yay, yay, I keep pushing it back but it'll be really sweet once its finished.


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

<mx:ApolloApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">

<mx:Style>

.main{

top:0;

left:0;

bottom:0;

right:0;

}

.address{

top:0;

left:0;

}

.content{

top:50;

left: 30;

right: 30;

bottom: 10;

}

</mx:Style>



<mx:Model id="browserObj">

<root>

<location></location>

</root>

</mx:Model>



<mx:Script>

<![CDATA[

private function updateLocation(_loc:String):void{

trace('Address: ' + _loc);

browserObj.location = _loc;

trace('HTML Page Location: ' + htmlPage.location);

}

]]>

</mx:Script>

<mx:Panel styleName="main" label="Apollo Browser">



<mx:HBox>

<mx:ComboBox id="protocol">

<mx:dataProvider>

<mx:Array>

<mx:String>http:// </mx:String>

<mx:String>https:// </mx:String>

<mx:String>ftp:// &lt;/mx:String>

&lt;/mx:Array>

&lt;/mx:dataProvider>

&lt;/mx:ComboBox>

&lt;mx:TextInput id="address" styleName="address" text="http://www.google.com/" />

&lt;mx:Button label="Go!" click="updateLocation(protocol.selectedItem + address.text)" />

&lt;/mx:HBox>



&lt;mx:HTML height="{this.height - 100}" id="htmlPage" styleName="content" location="{browserObj.location}" />



&lt;/mx:Panel>

&lt;/mx:ApolloApplication>



**disclaimer
This is not my concept of a well-coded/designed application, it is simply a test app. Take it for what it is.

Cheers.

No comments: