?? airintrospector.js
字號:
}else{
if(loadDebugger.htmlLoader.window.initCallbacks){
loadDebugger.htmlLoader.window.initCallbacks.push(callback);
}else{
loadDebugger.initCallbacks.push(callback);
}
}
return;
}
if(typeof loadDebugger.initCallbacks=='undefined'){
loadDebugger.initCallbacks = [function(){
delete loadDebugger.initCallbacks;
}, callback];
}else{
loadDebugger.initCallbacks.push(callback);
}
if(isAppSandbox){
htmlLoader = air.Introspector.runtime.HTMLLoader.createRootWindow(false);
air.Introspector.addEventListener(htmlLoader, air.Introspector.runtime.Event.HTML_DOM_INITIALIZE, function(){
try{
air.Introspector.removeEventListener(htmlLoader, air.Introspector.runtime.Event.HTML_DOM_INITIALIZE, arguments.callee);
htmlLoader.window.initCallbacks = loadDebugger.initCallbacks;
htmlLoader.window.isLoaded = false;
htmlLoader.window.config = air.Introspector.config;
htmlLoader.window.activateDebug = activateDebug;
htmlLoader.window.isAppSandbox = isAppSandbox;
}catch(e){
air.Introspector.runtime.trace(e);
air.Introspector.runtime.trace(e.line);
}
});
htmlLoader.window.isLoaded = false;
var nativeWindow = htmlLoader.stage.nativeWindow;
nativeWindow.width = 640;
nativeWindow.height = 480;
air.Introspector.addEventListener(htmlLoader, runtime.flash.events.HTMLUncaughtScriptExceptionEvent.UNCAUGHT_SCRIPT_EXCEPTION, function(e){
air.Introspector.logError(e.exceptionValue, {htmlLoader: self.htmlLoader});
e.preventDefault();
});
if(typeof air.Introspector.config.useAirDebugHtml=='undefined'||air.Introspector.config.useAirDebugHtml==false){
htmlLoader.loadString(air.Introspector.contentString);
}else{
htmlLoader.load(new air.Introspector.runtime.URLRequest('app:/DebugUI.html'));
}
}else{
air.Introspector.noBridge(function(){
var w = air.Introspector.tryCreateWindow(loadDebugger.initCallbacks);
if(w){
var htmlLoader = {window: w};
loadDebugger.htmlLoader = htmlLoader;
}
});
}
loadDebugger.htmlLoader = htmlLoader;
},
/**
* @function findDebugWindow
* @description Look up the Introspector in other windows. Maybe somebody else just opened it before us.
*/
findDebugWindow: function(){
if(isAppSandbox){
try{
if(air.Introspector.debugWindow&&air.Introspector.debugWindow.nativeWindow.closed==false)
return air.Introspector.debugWindow;
}catch(e){
}
try{
var htmlWindows = air.Introspector.getHtmlWindows(true);
for(var i=htmlWindows.length-1;i>=0;i--){
try{
if(typeof htmlWindows[i].htmlLoader.window.air!='undefined'
&& typeof htmlWindows[i].htmlLoader.window.air.Introspector!='undefined'
&& typeof htmlWindows[i].htmlLoader.window.air.Introspector.debugWindow!='undefined'
&& htmlWindows[i].htmlLoader.window.air.Introspector.debugWindow.nativeWindow.closed==false
&& htmlWindows[i].htmlLoader.window.isAppSandbox )
{
return htmlWindows[i].htmlLoader.window.air.Introspector.debugWindow;
}
}catch(e){
//this window is not initialized yet
//just get next window
}
}
}catch(e){}
}else{
return air.Introspector.debugWindow;
}
return null;
},
//application browser formats
// 0 - text
// 1 - images
// 2 - xml (you may want to add your own xml type here)
formats : { 'png':1, 'gif':1, 'zip':1, 'air':1, 'jpg':1, 'jpeg':1,
'txt':0, 'html':0, 'js':0, 'xml':2, 'opml':2, 'css':0, 'htm':0, '':0 },
/**
* @function canInit
* @description Check if we got parentSandboxBridge available
* @disabled
*/
canInit: function(){
/* if(!isAppSandbox&&typeof parentSandboxBridge=='undefined'){
alert('You need to include AIRIntrospector.js in application sandbox too!');
return false;
}*/
return true;
},
/**
* @function logArguments
* @description
*/
logArguments: function(args, config){
if(!air.Introspector.canInit()) return;
config.timestamp = new Date();
air.Introspector.init(config.type=='error', true, function(){
air.Introspector.debugWindow.logArguments(args, config);
});
},
/**
* @function logError
* @description
*/
logError: function(error, config){
air.Introspector.init(false, true, function(){
air.Introspector.debugWindow.logError(error, config);
});
},
/**
* @function showCssElement
* @description
*/
showCssElement: function(element){
var debugWindow = air.Introspector.findDebugWindow();
if(debugWindow){
debugWindow.showCssElement(element);
}
},
/**
* @function findLoader
* @description Finds the first HTMLLoader in flash display object list
*/
findLoader: function (stage){
try{
for(var i=stage.numChildren-1;i>=0;i--){
var child = stage.getChildAt(i);
var str=child.toString();
if(str=='[object HTMLLoader]'||child.name=="FlexHTMLLoader7"){
return child;
}
}
for(var i=stage.numChildren-1;i>=0;i--){
var child = stage.getChildAt(i);
var loader = air.Introspector.findLoader(child);
if(loader!=null)
return loader;
}
}catch(e){
}
return null;
},
/**
* @function getHtmlWindows
* @description Returns an array of all HTML windows
*/
getHtmlWindows: function(includeInspectors){
if(isAppSandbox){
var windowNodes = [];
var windows = air.Introspector.runtime.NativeApplication.nativeApplication.openedWindows;
for(var i=windows.length-1;i>=0;i--){
var loader = air.Introspector.findLoader(windows[i].stage);
if(loader!=null){
if(typeof includeInspectors=='undefined' && typeof loader.window!='undefined' && typeof loader.window.air!='undefined' && typeof loader.window.air.Introspector!='undefined' &&
typeof loader.window.air.Introspector.localIframeDebug != 'undefined' )
continue;
windowNodes.push({
nativeWindow: windows[i],
stage: windows[i].stage,
htmlLoader : loader
});
}
}
return windowNodes;
}else{
//should not be here
return [];
}
},
/**
* @function twoDigits
* @description int 2 string with two digits
*/
twoDigits: function(val){
if(val<10) return '0'+val;
return val+'';
},
/**
* @function escapeHtml
* @description Escapes html in order to display it in html
*/
escapeHtml: function(html){
return (html+'').replace(/&/g, '&').replace(/"/g, """).replace(/</g, '<').replace(/>/g, '>');
},
tree: { },
/**
* @function isNumberObject
* @description
*/
isNumberObject: function(obj){
try{
//can we catch isNaN only for NaN
return (obj+0==obj&&!isNaN(obj));
}catch(e){
}
return false;
},
/**
* @function isStringObject
* @description
*/
isStringObject: function(obj){
try{
return (typeof(obj.match) != "undefined" && obj.match.toString().indexOf("[native code]")>0);
}catch(e){
}
return false;
},
/**
* @function isDateObject
* @description
*/
isDateObject: function(obj){
try{
return (typeof(obj.getDate) != "undefined" && obj.getDate.toString().indexOf("[native code]")>0);
}catch(e){
}
return false;
},
/**
* @function isArgumentsObject
* @description
*/
isArgumentsObject: function(obj){
try{
return obj.toString()=='[object Arguments]';
}catch(e){
}
return false;
},
/**
* @function isXMLObject
* @description
*/
isXMLObject: function(obj){
try{
if(obj.xmlVersion&&obj.firstChild!=null)
return obj.xmlVersion!='';
}catch(e){
}
return false;
},
/**
* @function isArrayObject
* @description
*/
isArrayObject: function(obj){
try{
return (typeof(obj.push) != "undefined" && obj.push.toString().indexOf("[native code]")>0);
}catch(e){
}
return false;
},
/**
* @function isItemNative
* @description
*/
isItemNative: function(obj){
try{
return (typeof(obj.item) != "undefined" && obj.item.toString().indexOf("[native code]")>0);
}catch(e){
}
return false;
},
/**
* @function dump
* @description
*/
dump: function (obj, levels, level){
if(air.Introspector.isArgumentsObject(obj)&&obj.length==1)
return air.Introspector.dump(obj[0]);
if(typeof levels=='undefined') { levels=1; }
if(typeof level=='undefined') { level=0; }
try{
if(typeof obj=='undefined'){ return '[undefined]'; }
if(obj==null){ return '[null]'; }
var list = [];
// if(air.Introspector.isXMLObject(obj)){
// disable for the moment
// return;
// }
if(air.Introspector.isStringObject(obj)
||air.Introspector.isNumberObject(obj)
||air.Introspector.isDateObject(obj)){
if(level==0){
try{
return obj+'';
}catch(e){
return e+'';
};
}
return'';
}
var isItemNative = air.Introspector.isItemNative(obj);
var parseArray = air.Introspector.isArrayObject(obj)||air.Introspector.isArgumentsObject(obj)||isItemNative;
var parseHash = !parseArray || isItemNative;
if (parseArray){
var l = obj.length;
for(var i=0;i<l;i++){
var value;
try{
value = obj[i];
if(typeof value=='undefined') {value = '[undefined]'};
}catch(e){
value = e+'';
}
list.push([i,value]);
}
}
if(parseHash) {
for(var i in obj){
var value;
try{
value = obj[i];
if(typeof value=='undefined') {value = '[undefined]'};
}catch(e){
value = e+'';
}
list.push([i,value]);
}
}
if(air.Introspector.config.debugRuntimeObjects){
try{
var typeDescription = runtime.flash.utils.describeType(obj);
if(!this.domParser) this.domParser = new DOMParser();
var typeXml = this.domParser.parseFromString(typeDescription, "text/xml");
var child = typeXml.firstChild.firstChild;
while(child){
if(child.nodeName=='accessor'||child.nodeName=='constant'||child.nodeName=='method'||child.nodeName=='variable'){
var name = child.getAttribute('name');
if(name!=null && name!='prototype'){
try{
list.push([name,obj[name]]);
}catch(e){
list.push([name,'']+'');
}
}
}
child = child.nextSibling;
}
}catch(e){
//just hide the error
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -