View Full Version : HTMLLoader.window

09-05-2008, 04:40 AM
I'm really confused about the behavior I'm getting from HTMLLoader.window. Follow the traces:

import flash.html.*;

var htmlLoader = HTMLLoader.createRootWindow();
htmlLoader.loadString("<html><script language='Javascript'>function testFunc(){alert('test')}</script><body><p>Hello World</p></body></html>");

function htmlDOMInitialize(evt){
trace(htmlLoader.window); // [object DOMWindow]
trace(htmlLoader.window.print); // function print() { [native code] }
trace(htmlLoader.window.window); // [object DOMWindow]
trace(htmlLoader.window.window.print); // function print() { [native code] }
htmlLoader.window.print(); // no error, does nothing
htmlLoader.window.window.print(); // no error, does nothing
htmlLoader.window.testFunc(); // TypeError: Error #1006: testFunc is not a function

Can anyone explain that mess? What is window.window vs window? Why doesn't print() do anything? Why does testFunc() throw an error -- shouldn't the DOM be initialized?