Is HTMLLoader connected after Event.COMPLETE
event? You might even expect the HTMLLoader document to fire the DOMReady event before binding it to the step.
Try something like this:
_htmlLoader = new HTMLLoader(); _htmlLoader.paintsDefaultBackground = false; var urlRequest:URLRequest = new URLRequest(urlRequest); _htmlLoader.addEventListener(Event.COMPLETE, completeHandler); _htmlLoader.load(urlRequest); function completeHandler(event:Event):void { _htmlLoader.window.document.addEventListener("DOMContentLoaded", readyHandler); } function readyHandler(event:Event):void { _stage.addChild(_htmlLoader); }
The Flex documentation on HTML event handling mentions the following:
When a listener refers to a specific DOM element, it is good practice to wait for the parent HTMLLoader to dispatch the full event before adding event listeners. HTML pages often load multiple files and the HTML DOM is not fully created until all files have been downloaded and parsed. HTMLLoader dispatches the full event when all elements are created.
Perhaps the HTMLLoader joins the stage before the document is really ready, which may explain some oddities.
If you have more information that would be amazing help ...
source share