В руте лежат:
кнопки go, back, forward, abort,
поле ввода addr_input,
клип ext_bounds (область для окна браузера).
import mx.utils.Delegate;
//Общие настройки
Stage.align="TL";
Stage.scaleMode="noScale";
this.addr_input.backgroundColor=0xEEEEEE;
this.addr_input.borderColor=0x999999;
this.sending_lc = new LocalConnection();
this.receiving_lc = new LocalConnection();
//Разбор командной строки
this.params_object=new Object();
for (var i:Number=1;i<10;i++) {
var params_item:Array=mdm.Application.getCMDParams(i).split("=");
this.params_object[params_item[0]]=params_item[1];
}
if (this.params_object.path==null) this.params_object.path="";
if (this.params_object.pckg!=null) this.params_object.pckg=this.params_object.pckg.split(".").join("\\")+"\\"; else this.params_object.pckg="";
if (this.params_object.clss!=null) this.params_object.clss+=".html";
else {
if (this.params_object.pckg!="") this.params_object.pckg+="class-list.html";
this.params_object.clss="";
}
if (this.params_object.item!=null) this.params_object.item="#"+this.params_object.item; else this.params_object.item="";
if (this.params_object.kind==null) this.params_object.kind="";
if (this.params_object.kind=="function") this.params_object.item+="()";
if (this.params_object.file==null) this.params_object.file=this.params_object.pckg+this.params_object.clss;
if (this.params_object.file=="") this.params_object.file="index.html";
//Инициализация
this.paths_xml=new XML();
this.paths_xml.onLoad=Delegate.create(this,
function(success:Boolean) {
//*****************
if (!success) {
this.addr_input.text="Configuration file not found";
return;
}
//Ищем первый подходящий путь
this.addr_string="";
if (this.params_object.path!="") {
this.addr_string=this.params_object.path+this.params_object.file;
} else {
var xml_node:XMLNode=this.paths_xml.firstChild;
while (xml_node.nodeName!="paths") xml_node=xml_node.nextSibling;
xml_node=xml_node.firstChild;
var found:Boolean=false;
var first_path:String="";
while (xml_node!=null) {
if (xml_node.nodeName=="path") {
var path_str:String=xml_node.firstChild.toString();
this.addr_string=path_str+this.params_object.file;
if (first_path=="") first_path=this.addr_string;
if (mdm.FileSystem.fileExists(this.addr_string)) {
found=true;
break;
}
}
xml_node=xml_node.nextSibling;
}
if (!found) this.addr_string="";
}
if (this.addr_string!="") this.addr_string+=this.params_object.item;
//проверка на предыдущий запуск программы
this.sending_lc.onStatus=Delegate.create(this,
function(infoObject:Object) {
switch (infoObject.level) {
case 'status' :
mdm.Application.exit();
break;
case 'error' :
this.receiving_lc.reloadContent=Delegate.create(this,
function(addr_string:String) {
this.myBrowser.goto(addr_string);
mdm.Application.bringToFront();
}
);
this.receiving_lc.connect("test_previous_copy");
mdm.Application.onAppExit=Delegate.create(this,
function(){ this.receiving_lc.close();
}
);
break;
}
}
);
this.sending_lc.send("test_previous_copy", "reloadContent", this.addr_string);
//Инициализация браузера
this.addr_input.text=this.addr_string;
this.myBrowser = new mdm.Browser(0, 0, 0, 0, this.addr_string, false)
this.myBrowser.onDocumentComplete=Delegate.create(this,
function() {
this.addr_input.text=this.myBrowser.url;
}
);
this.delta_x=Stage.width-this.ext_bounds._width;
this.delta_y=Stage.height-this.ext_bounds._height;
this.onResize = function (){
this.ext_bounds._width=Stage.width-this.delta_x;
this.ext_bounds._height=Stage.height-this.delta_y;
this.myBrowser.x=Math.round(this.ext_bounds._x);
this.myBrowser.y=Math.round(this.ext_bounds._y);
this.myBrowser.width=Math.round(this.ext_bounds._width);
this.myBrowser.height=Math.round(this.ext_bounds._height);
}
Stage.addListener(this);
this.onResize();
this.go.onRelease=Delegate.create(this,
function() {
this.myBrowser.goto(this.addr_input.text);
}
);
this.back.onRelease=Delegate.create(this,
function() {
this.myBrowser.back();
}
);
this.forward.onRelease=Delegate.create(this,
function() {
this.myBrowser.forward();
}
);
this.abort.onRelease=Delegate.create(this,
function() {
this.myBrowser.stop();
}
);
this.onKeyDown = function() {
if (Key.isDown(Key.ENTER)) {
this.myBrowser.goto(this.addr_input.text);
}
}
Key.addListener(this);
//*****************
}
);
this.paths_xml.load("configuration.xml");
//Общие настройки
Stage.align="TL";
Stage.scaleMode="noScale";
this.addr_input.backgroundColor=0xEEEEEE;
this.addr_input.borderColor=0x999999;
this.sending_lc = new LocalConnection();
this.receiving_lc = new LocalConnection();
//Разбор командной строки
this.params_object=new Object();
for (var i:Number=1;i<10;i++) {
var params_item:Array=mdm.Application.getCMDParams(i).split("=");
this.params_object[params_item[0]]=params_item[1];
}
if (this.params_object.path==null) this.params_object.path="";
if (this.params_object.pckg!=null) this.params_object.pckg=this.params_object.pckg.split(".").join("\\")+"\\"; else this.params_object.pckg="";
if (this.params_object.clss!=null) this.params_object.clss+=".html";
else {
if (this.params_object.pckg!="") this.params_object.pckg+="class-list.html";
this.params_object.clss="";
}
if (this.params_object.item!=null) this.params_object.item="#"+this.params_object.item; else this.params_object.item="";
if (this.params_object.kind==null) this.params_object.kind="";
if (this.params_object.kind=="function") this.params_object.item+="()";
if (this.params_object.file==null) this.params_object.file=this.params_object.pckg+this.params_object.clss;
if (this.params_object.file=="") this.params_object.file="index.html";
//Инициализация
this.paths_xml=new XML();
this.paths_xml.onLoad=Delegate.create(this,
function(success:Boolean) {
//*****************
if (!success) {
this.addr_input.text="Configuration file not found";
return;
}
//Ищем первый подходящий путь
this.addr_string="";
if (this.params_object.path!="") {
this.addr_string=this.params_object.path+this.params_object.file;
} else {
var xml_node:XMLNode=this.paths_xml.firstChild;
while (xml_node.nodeName!="paths") xml_node=xml_node.nextSibling;
xml_node=xml_node.firstChild;
var found:Boolean=false;
var first_path:String="";
while (xml_node!=null) {
if (xml_node.nodeName=="path") {
var path_str:String=xml_node.firstChild.toString();
this.addr_string=path_str+this.params_object.file;
if (first_path=="") first_path=this.addr_string;
if (mdm.FileSystem.fileExists(this.addr_string)) {
found=true;
break;
}
}
xml_node=xml_node.nextSibling;
}
if (!found) this.addr_string="";
}
if (this.addr_string!="") this.addr_string+=this.params_object.item;
//проверка на предыдущий запуск программы
this.sending_lc.onStatus=Delegate.create(this,
function(infoObject:Object) {
switch (infoObject.level) {
case 'status' :
mdm.Application.exit();
break;
case 'error' :
this.receiving_lc.reloadContent=Delegate.create(this,
function(addr_string:String) {
this.myBrowser.goto(addr_string);
mdm.Application.bringToFront();
}
);
this.receiving_lc.connect("test_previous_copy");
mdm.Application.onAppExit=Delegate.create(this,
function(){ this.receiving_lc.close();
}
);
break;
}
}
);
this.sending_lc.send("test_previous_copy", "reloadContent", this.addr_string);
//Инициализация браузера
this.addr_input.text=this.addr_string;
this.myBrowser = new mdm.Browser(0, 0, 0, 0, this.addr_string, false)
this.myBrowser.onDocumentComplete=Delegate.create(this,
function() {
this.addr_input.text=this.myBrowser.url;
}
);
this.delta_x=Stage.width-this.ext_bounds._width;
this.delta_y=Stage.height-this.ext_bounds._height;
this.onResize = function (){
this.ext_bounds._width=Stage.width-this.delta_x;
this.ext_bounds._height=Stage.height-this.delta_y;
this.myBrowser.x=Math.round(this.ext_bounds._x);
this.myBrowser.y=Math.round(this.ext_bounds._y);
this.myBrowser.width=Math.round(this.ext_bounds._width);
this.myBrowser.height=Math.round(this.ext_bounds._height);
}
Stage.addListener(this);
this.onResize();
this.go.onRelease=Delegate.create(this,
function() {
this.myBrowser.goto(this.addr_input.text);
}
);
this.back.onRelease=Delegate.create(this,
function() {
this.myBrowser.back();
}
);
this.forward.onRelease=Delegate.create(this,
function() {
this.myBrowser.forward();
}
);
this.abort.onRelease=Delegate.create(this,
function() {
this.myBrowser.stop();
}
);
this.onKeyDown = function() {
if (Key.isDown(Key.ENTER)) {
this.myBrowser.goto(this.addr_input.text);
}
}
Key.addListener(this);
//*****************
}
);
this.paths_xml.load("configuration.xml");
Файл конфигурации:
<paths>
<path>D:\Documentation\Flex\langref\</path>
<path>D:\Documentation\APE\api\</path>
<path>D:\Documentation\Fisix\API\</path>
</paths>
<path>D:\Documentation\Flex\langref\</path>
<path>D:\Documentation\APE\api\</path>
<path>D:\Documentation\Fisix\API\</path>
</paths>