There is nothing big or clever about this, but it made me laugh at how easy it was to get a very basic web browser working in Apollo. So for those interested here is a very basic 'web page loading application'
Get the AIR file here
Here is the source
-
<?xml version="1.0" encoding="utf-8"?>
-
<mx:ApolloApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="820" height="640">
-
<mx:Script>
-
<![CDATA[
-
private function loadURL(uri:String) :void
-
{
-
browser.location = uri;
-
}
-
]]>
-
</mx:Script>
-
<mx:Panel id="holder_panel" layout="absolute" width="100%" height="100%" x="0" y="0">
-
<mx:HTML id="browser" width="100%" height="80%" y="30" />
-
<mx:Button x="683" y="5" label="GO" click="loadURL(url_txt.text)"/>
-
<mx:TextInput id="url_txt" x="95" y="5" width="581" editable="true" enabled="true" />
-
</mx:Panel>
-
</mx:ApolloApplication>
The problem with that hack is that the address bar and the page loaded are only linked in one direction. So I added in this:
-
<mx:Script>
-
<![CDATA[
-
private function setURL(uri:String) :void
-
{
-
url_txt.text = uri;
-
}
-
]]>
And added in an event change here:
-
<mx:HTML id="browser" width="100%" height="80%" y="30" locationChange="setURL(browser.location)" />
So my little hacked browser code now looks like this.
-
<?xml version="1.0" encoding="utf-8"?>
-
<mx:ApolloApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="820" height="640">
-
<mx:Script>
-
<![CDATA[
-
private function loadURL(uri:String) :void
-
{
-
browser.location = uri;
-
}
-
-
private function setURL(uri:String) :void
-
{
-
url_txt.text = uri;
-
}
-
]]>
-
</mx:Script>
-
<mx:Panel id="holder_panel" layout="absolute" width="100%" height="100%" x="0" y="0">
-
<mx:HTML id="browser" width="100%" height="80%" y="30" locationChange="setURL(browser.location)" />
-
<mx:Button id="go_btn" x="683" y="5" label="GO" click="loadURL(url_txt.text)"/>
-
<mx:TextInput id="url_txt" x="95" y="5" width="581" editable="true" enabled="true" />
-
</mx:Panel>
-
</mx:ApolloApplication>
As I already noted this isn't anything special and certainly won't be winning any prizes, but it just amused me that you can achieve this much will relatively little code.
Way to go Flex and Apollo :D
License
This work is published under a CC-GNU LGPL.
[…] bulk of the code is pilfered from flashgen.com, obviously the addition of the colour picker is where the bulk of the work was, that and getting […]