Question

I have a VBox that I am populating programatically, After a particular event (dragDrop) I do some calculations, reorder some variables, then re-build the VBox. This all works great, but I want the VBox to scroll back to the correct verticalScrollPosition. I tried even the simplest thing:

myVBox.verticalScrollPosition = 200

But I just can't get it to set the scroll position after it's rebuilt. Any ideas?

Edit: per Franky's response I realized that my dragDrop function was calling the rebuilder function then the position setter function back to back, which means it wasn't done being built when it was trying to set. Now I'm passing the position I want the box set to to the rebuilder function which sets the scroll position at the end of building the VBox and everything works out great.

Was it helpful?

Solution

Try adding this code, I'm at work so I can't verify if it works, hope so:

//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()
            });
    }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top