vendredi 7 avril 2017

actionscript 3 contentHeight not updating properly

I am using Adobe Flash Builder with actionscript to make a desktop application. I am getting some html code from a webpage and putting it into an mx:html element, then attempting to get the content height in order to determine if I should hide the vertical scrollbar or not. However, when using contentHeight it seems to return the height of the previous state of the element, rather than the one just set.

This is the code to fetch the html page

var htmlPageRequest:URLRequest = new URLRequest(url); 
htmlPageRequest.method = URLRequestMethod.GET; //set request's html request method to GET

htmlPageLoader.addEventListener(Event.COMPLETE, onHtmlLoaded); //listen for page load
htmlPageLoader.load(htmlPageRequest);//when loaded continue logic in new function   

This is the function that is run when the page request is complete

private function onHtmlLoaded(e:Event):void { //logic after html page has loaded 
   =; //set content

            //determine if vscroll bar should be visible
            if(HtmlElement.contentHeight > HtmlElement.height) {
                scrollbar.visible = true; 
            else {
                scrollbar.visible = false;


Aucun commentaire:

Enregistrer un commentaire