动作3:保持焦点的闪存嵌入损失的textarea的UIScrollBar位置闪存、损失、位置、动作

2023-09-08 15:27:13 作者:幽香清远

我使用Flash CS4。一切功能,因为它应该在CS4 $ P $编译后pviews瑞士法郎。

I'm using Flash CS4. Everything functions as it should when CS4 previews the swf after compiling it.

不过,嵌入闪存的项目在网页中,如果文本区域失去焦点的闪片内后,textarea的的内置的UIScrollBar重置到顶部。

However, after embedding the flash item in a webpage, if the textArea loses focus within the flash piece, the textarea's built-in UIscrollbar resets to the very top.

这就是它与众不同:如果我添加一个FOCUS_OUT事件监听器textarea的存储当前滚动值,我发现滚动条价值已经恢复到最小甚至在FOCUS_OUT事件被触发!跆拳道?

Here's the kicker: if I add a FOCUS_OUT event listener to the textArea to store the current scrollbar value, I find that the scrollbar value has been reset to minimum even before the FOCUS_OUT event is triggered! WTF?

我认为这正在发生,因为textarea的的的htmlText属性为动态填充。 Adobe AIR的拥有先进的移交HTML的方法,而不是简单的AS3,哦,不。如何讨厌。有什么可以做?

I think this is occurring because the textArea's htmlText propery is dynamically populated. Adobe AIR has advanced methods for handing HTML, but not simple AS3, oh no. How obnoxious. What can be done?

推荐答案

我从来没有想过我会回答我的问题,但在这里它是。原来使用htmlText的事情可能是一个谣传。滚动条抖动发生在动态生成的内容窗口被点击,它失去焦点之间,所以这抓住了当前位置和是否滚动条的在上单击事件的底部,并通过这些信息对焦点事件。 displayWindow是一个动态生成的内容。

I never thought I'd answer my own question, but here it is. Turns out the htmlText thing may have been a canard. The scrollbar jitter happens in between the dynamically generated content window's being clicked and its losing focus, so this captures the current position and whether the scrollbar's at the bottom on the click event and passes that info to the focus event. displayWindow is the one with dynamically generated content.

我是比较新的AS3,所以让我知道是否有任何这不是犹太教。

I am relatively new to AS3, so let me know if any of this isn't kosher.

displayWindow.addEventListener(MouseEvent.ROLL_OUT, handleClick);
function handleClick(event:MouseEvent):void
{
    //here, user has clicked output window
    var currentPosition = displayWindow.verticalScrollPosition;
    var atTheBottom:Boolean = (currentPosition == displayWindow.maxVerticalScrollPosition);
   var focusAdded:Boolean = false;
   displayWindow.addEventListener(FocusEvent.FOCUS_OUT, 
   function handy() {
        //here, user has clicked away from output window  

       if (!focusAdded) {
            if (atTheBottom)
                displayWindow.verticalScrollPosition = displayWindow.maxVerticalScrollPosition;
            else
                displayWindow.verticalScrollPosition = currentPosition;

            focusAdded = true;

        } else {
            displayWindow.removeEventListener(FocusEvent.FOCUS_OUT, handy);
            focusAdded = false;
        }
    }
   );
}