كيف تخبر Scrollpane بالتمرير لأعلى أو لأسفل باستخدام ActionScript؟
-
04-07-2019 - |
سؤال
أرغب في تشغيل حدث يتسبب في بدء التمرير لأعلى أو لأسفل.
من الناحية المثالية ، ستستمر التمرير في التمرير على طول الطريق لأعلى أو لأسفل ما لم يتم إلغاؤه بواسطة حدث آخر.
المحلول
سيكون شيئًا كهذا:
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;
}
سيتعين عليك التحقق من _hmax و _vmax للتأكد من عدم التمرير وراء نهاية المحتوى ، حيث يتوقف شريط التمرير بشكل طبيعي. لا أتذكر الجزء العلوي من رأسي ما هي أسماء هذه المتغيرات ، ولكن إذا قمت بتشغيل برنامجك في وضع التصحيح والوصول إلى مثيل Scrollpane ، فيجب أن تجده. من المحتمل أن يكون الأمر أسهل إذا قمت بنقل شريط التمرير المدمج إلى الأسفل ومعرفة التغيير المتغير ، ثم ابحث عن تلك التي تتطابق مع الساكنة.
لا تنتمي إلى StackOverflow