代码之家  ›  专栏  ›  技术社区  ›  invertedSpear

设置垂直滚动位置不工作

  •  1
  • invertedSpear  · 技术社区  · 15 年前

    myVBox.verticalScrollPosition = 200
    

    但我就是无法让它在重建后设置滚动位置。有什么想法吗?

    编辑:根据Franky的回答,我意识到我的dragDrop函数在背靠背地调用重建函数,然后调用位置设置器函数,这意味着它在尝试设置时没有完成构建。现在,我将要将框设置为的位置传递给重建器函数,该函数在构建VBox结束时设置滚动位置,一切都很顺利。

    1 回复  |  直到 15 年前
        1
  •  1
  •   Fseee    15 年前

    尝试添加此代码,我正在工作,因此无法验证它是否有效,希望如此:

    //Initialize the Vbox
    public var myVbox:VBox = new VBox();
    //Define the function which rebuilds the Vbox
    public function rebuildVbox():VBox{  
    myVbox.verticalScrollPosition=200;
    return myVbox
    }
    //Define your event.complete function which sets the verticalScrollPosition  
    //after the drag drop
    public function setVerticalScrollPosition():void{
        myVbox.addEventListener(Event.COMPLETE,function(event:Event):void{
                rebuildVbox()
                });
        }
    
    推荐文章