views:

561

answers:

1

I want to trigger an event that causes the ScrollPane to start scrolling up or down.

Ideally the ScrollPane would scroll continue to scroll all the way up or down unless canceled by another event.

+1  A: 

Would be something like this:

this.createClassObject(mx.containers.ScrollPane, "my_sp", 10);
my_sp.setSize(360, 280);
this.createEmptyMovieClip("button_up",this.getNextHighestDepth());
this.createEmptyMovieClip("button_down",this.getNextHighestDepth());
this.createEmptyMovieClip("button_left",this.getNextHighestDepth());
this.createEmptyMovieClip("button_right",this.getNextHighestDepth());

button_up.onPress=function(){
     my_sp.onEnterFrame=function(){
          this.vPosition -= 5;
     }
}

button_down.onPress=function(){
     my_sp.onEnterFrame=function(){
          this.vPosition += 5;
     }
}
button_left.onPress=function(){
     my_sp.onEnterFrame=function(){
          this.hPosition -= 5;
     }
}

button_right.onPress=function(){
     my_sp.onEnterFrame=function(){
          this.hPosition += 5;
     }
}

//replace this with whatever event you want to use to make the scrolling stop
button_right.onRollOut = button_left.onRollOut = button_up.onRollOut = button_down.onRollOut = function(){
      my_sp.onEnterFrame=undefined;
}

You'll have to check the _hmax and _vmax to make sure you don't scroll past the end of the content, where the scrollbar would naturally stop at. I don't remember off the top of my head what the names of these variables are, but if you run your program in debug mode and poke around the scrollpane instance, you should find it. It'll probably be easier if you move the built-in scrollbar to the bottom and see what variable changes, then find the one that matches and is static.

Sorry, forgot to throw in there that you need to actually put something in those buttons so they're not just empty movie clips and can actually act like buttons :)
The property is : maxVPosition (in case someone is looking for the name)
Nordes
http://asji-lab.blogspot.com/2005/10/scrollpane-scrollbar-and-scroll-to.html <== for more information about scrolling in a scrollpane.
Nordes