// Create the web browser control
var ax = createControl("Shell.Explorer.2", 0, 0, 200, 200);
// Fill the web browser control in the entire client area of the main window
getMainWnd().onSize = function(type, width, height)
{
ax.window.move(0, 0, width, height);
}
// handle event of the ActiveX control
ax.activex.NavigateComplete2 = function (control, url)
{
trace(url);
}
// Browse web site
// The ActiveXObject accepts case insensitive method names.
// Please be careful that both FFish script and Action script
// are case sensitive
ax.activex.navigate2("http://www.topcmm.com");
Although you can also write code in action script to embed a web browser control, you would have to wrap the web browser control in an Action script class, because Action script does not allow you to call a dynamic method that is not defined in a class. A sample wrapper class, "WebBrowser.as", which defines only one method of the web browser, is as follows
import SWFKit.*;
import flash.external.*;
class WebBrowser extends SWFKit.ActiveXObject
{
public function WebBrowser(progID)
{
super(progID);
}
public static function fromID(id: Number)
{
var ax = new WebBrowser(null);
ax.Identifier = id;
return ax;
}
public function Navigate2()
{
return ExternalInterface.call("ffish_call2", this.Identifier,
"Navigate2", arguments);
}
// the other methods ...
}
The following code shows how to use the web browser in action script in Flash 8
import SWFKit.*;
import WebBrowser;
// Create the web browser control
var ax = Global.createControl("Shell.Explorer.2", 0, 0, 200, 200);
// Fill the web browser control in the entire client area of the
// main window
var win = Global.getMainWnd();
ax.window.move(0, 0, win.clientRect.width, win.clientRect.height);
function onSize(type, width, height)
{
ax.window.move(0, 0, width, height);
}
win.setEventHandler("onSize", onSize);
var wb = WebBrowser.fromID(ax.activex);
// handle event of the ActiveX control
function NavigateComplete2(control, url)
{
_root.strace(url);
}
wb.setEventHandler("NavigateComplete2", NavigateComplete2);
// Browse web site
wb.Navigate2("http://www.topcmm.com");
To learn how to embed an ActiveX control in a form, please read the "Creating multiple forms" tutorial.
The reference of reusing the web browser can be found at here