Monday, June 9, 2008

Flash AS3 based Web Browser

Flash has been slowly and steadily incorporating many new features day by day. Considering the wide range of support available for flash, One could expect a lot of internet and system applications in it. The initial Support offered by flash for making html request was limited to methods like LoadVars() and Load().

With Flash AS3, they have added an important class for making and handling HttpRequest. The class is URLLoader(). I tried to get the html contents from a html Page using the following bit of code. and to say the least it succeeded, quite nicely. At the next stage, I'll be trying to create a renderer in flash. This I believe will be the toughest part. This is the initial bit of code.

import flash.display.Sprite;

var loader:URLLoader;

var loadeddata:String;


//handling a button click event for clicking the go button

function handleGoClick( e:Event ):void {
Text1.text = "";
Status1.text = "";
Status2.text = "";
loader = new URLLoader(new URLRequest(Address.text));
loader.addEventListener( Event.COMPLETE, handleComplete );
loader.addEventListener(ProgressEvent.PROGRESS, handleProgress );
loader.addEventListener( HTTPStatusEvent.HTTP_STATUS, handleStatus );
loader.addEventListener( IOErrorEvent.IO_ERROR, handleIOError );

function handleIOError(e:IOErrorEvent):void {

Status2.text = e.text;

function handleProgress( e:Event ):void {
var percent:Number = Math.round( (e.currentTarget.bytesLoaded /
e.currentTarget.bytesTotal ) * 100 );

Status2.text = "loaded " +percent+ "% of "+Math.round(e.currentTarget.bytesTotal/1000)+ " KB";

function handleComplete( e:Event ):void {

Text1.text =;

function handleStatus(e:HTTPStatusEvent) :void {

if(e.status != 404)
Status1.text = "File Found:" +e.status+ " ";
Status1.text = "File Not Found:" +e.status+ " ";

ButtonGo.addEventListener(MouseEvent.CLICK, handleGoClick );

I have uploaded the files here :-

Flash Browser

Hope one day I can have a complete flash based web browser

You might need the latest version of adobe flash player for running the swf!!!!!

No comments: