All pastes #1062844 Raw Edit

Miscellany

public html v1 · immutable
#1062844 ·published 2008-07-05 06:38 UTC
rendered paste body
Hi, For the sake of helping a fellow learner (who stumbled on my topic via searching on the forums), here's what I have found:- Calling nativeWindow.close() with "HTMLLoader.createRootWindow(TRUE ..." never gave me any problems (so far :)  - Calling nativeWindow.close() on a hidden window which was brought back visible manually using activate() was the culprit, depending on how it has been activate()'dIn my testcase (below), using the activate() under the anonymous function defined in winbox_loadcomplete will throw the TypeError error mentioned in my other post. By commenting this activate() line and uncommenting showwindow() inside the string, everything will work fine, error-free.My guesses: either i am using the wrong object for remotely closing my window (HTMLLoader.window.nativeWindow.activate() ), or something obscure (I should read up more though) about the AIR security prevents me to do it remotely. Any guesses / ideas / pointers?Trimmed down source code: <html> <head> <title>nativeWindow.close() TypeError test case</title> </head> <body><h3>Isolated sample:<br />nativeWindow.close() throwing a TypeError</h3><div style="text-align: center;"><button id="window">Step 1: Popup window</button></div><p><b>Note</b>: The bug occurs when we're using the follwing path: HTMLLoader.window.nativeWindow.activate(),<br />calling from the parent (initial) window.<br /><br />By calling window.nativeWindow.activate() directly from the child window, the bug does <b>not</b> occur.</p><script type="text/javascript">	var winbox_window; // setting up as a global variable, just in case it would help.	winbox_loadcomplete = function() { 		//Using the following line will throw the TypeError: Undefined value		winbox_window.window.nativeWindow.activate();		//To see a working (bug-free) version, comment this above, and uncomment //showwindow() 		//in the winbox_body string below	}	document.getElementById('window').addEventListener("click",function() {		var winbox_options = new window.runtime.flash.display.NativeWindowInitOptions(); 		winbox_window = window.runtime.flash.html.HTMLLoader.createRootWindow(false, winbox_options, false, null); 		var winbox_body = '<html><head><title>test</title></head><body onload="//showwindow();"><script type="text/javascript">function showwindow() {window.nativeWindow.activate();}<\/script><span id="close">2. Close this window (by system chrome or by clicking thru text) to make the bug occur.<br />3. ??? (Look in the console)<br />4. Profit! (or not? :) )<\/span><script type="text/javascript">document.getElementById("close").addEventListener("click",function() { window.nativeWindow.close(); });<\/script><\/body><\/html>';		winbox_window.loadString(winbox_body);		winbox_window.addEventListener(window.runtime.flash.events.Event.COMPLETE,winbox_loadcomplete);	});</script></body></html>