I'm trying to use an HTML component to do some of the rendering in my application and I need to be able to scroll the content to the bottom as things get added to it. It looks like I should be able to use the verticalScrollPosition property of the HTML component (which should correctly set the scrollV property on the htmlLoader). However, when I do this, I see the scrollbar jump to the bottom go immediately back to the top.
I'm logging the scrollV value of the htmlLoader when I do this and it looks like it's being set correctly (contentHeight - htmlLoader.height). On successive calls to set the verticalScrollPosition property, I can see that scrollV had been set correctly.
Anyone know what might be going wrong or encountered this problem before?
So, I think I figured this one out. I was setting the htmlText property of my HTML component when I wanted to add content. However, doing this causes the whole thing to redraw and scroll to the top. Unfortunately, this meant that I had to wait until getting an HTML_RENDER event before I could rescroll to the bottom and that sometimes even then it didn't work.
Instead, I now do everything using functions on the HTML DOM through ActionScript. So, instead of saying:
htmlText += "<p>blah<p>"
I am now using:
var p:* = html.htmlLoader.window.document.createElement('p');
p.innerHTML = 'blah';
This keeps the existing html content intact and allows scrolling to work much better. It's just a little more lengthy in terms of amount of code.