View Full Version : [AS2] AxisScroller v2.0
mprzybylski
October 31st, 2007, 02:08 PM
I've updated my AxisScroller class to version 2.0. For changes, downloads, and other pertinent information, go here:
http://evolve.reintroducing.com/2007/10/31/as2/as2-axisscroller-v20/
prg9
October 31st, 2007, 02:45 PM
I've updated my AxisScroller class to version 2.0.
Thanks for sharing and updating, your stuff is always great. :pleased:
For me, I seem to witness a lag of sorts when pressing the arrows repeatedly? Meaning some times it appears they lack focus and it requires multiple clicks for further movement. It seems intermittent however and maybe has something to do with the "continuousScroll" method? Or maybe its setup to only allow movement after the previous scroll has come to a complete stop? (sorry haven't look at the code to well). Was just something I noticed when I was slamming the crap out of the buttons and being click happy and testing things out, but no serious even in normal use it seemed to be intermittent as described. (-: But maybe its just me here and its not buggy. The continuousScroll however is quie nice.
Also (again without looking to much) is it possible to setup somthing like scrollTo's if you will, to scroll to a certain position by chance. I was kind of thinking maybe its possible similiar to the reset feature but rather for sending the scroll to a location.
Regardless, the original was great the new one is great and your awesome for sharing. The new blog is super, thanks mprzybylski. Keep up the great work.
mprzybylski
October 31st, 2007, 03:12 PM
for the intermittent lag: it's probably because i had to come to a relatively good value for the feature to work. it runs every 80 ms on a timer when you hold the button down which was best in my eyes to allow the feature to work properly. if you want to you can go into the code and change the setInterval call to whatever works best for you.
as for the scrollTo: that's a GREAT idea. I'm going to add a method to do that, thanks for that!
prg9
October 31st, 2007, 03:29 PM
for the intermittent lag: it's probably because i had to come to a relatively good value for the feature to work. it runs every 80 ms on a timer when you hold the button down which was best in my eyes to allow the feature to work properly. if you want to you can go into the code and change the setInterval call to whatever works best for you.
Gotcha thanks! I should have looked further into myself. But glad to know.
as for the scrollTo: that's a GREAT idea. I'm going to add a method to do that, thanks for that!
Super :thumb2: Looking forward to it! I dont know what your thinking but I kind of had it in mind you could add the scrollTo call on additional mc buttons to take the scroller to certain content. I am sure there are other uses also. Thanks again mprzybylski, nice stuff as always!
mprzybylski
October 31st, 2007, 05:47 PM
well, i was trying to implement the scrollTo just now, but i couldnt get a good calculation of it and it wasn't working out accurately. I'll post the code here just in case anyone else wants to take a shot:
public function scrollTo($val:Number):Void
{
var percent:Number = ($val / this._toBeScrolled[this._changeProp]);
var scrollerPos:Number = (percent * this._track[this._changeProp]);
trace("CONTENT HEIGHT: " + this._toBeScrolled[this._changeProp] + " PERCENT: " + percent + " TRACK HEIGHT: " + this._track[this._changeProp] + " SCROLLER POS: " + scrollerPos);
this._scroller[this._axis] = (scrollerPos); // - this._scroller[this._changeProp]);
var n:Number = setInterval(this, "tracePos", 2000);
}
private function tracePos():Void
{
trace(this._toBeScrolled[this._axis]);
}
keep in mind this isn't finalized code so its not too pretty, but it would be something along these lines i'd imagine.
i was just using the tracePos() method to see what the position of the content would be after running the scrollTo method. I just put this stuff right after the reset method in the code so you can get started in testing it by doing that and then just making a button that calls scroller.scrollTo(500); or whatever.
i'm not math genius by any means so this may be a bit beyond me.
prg9
November 1st, 2007, 12:01 AM
well, i was trying to implement the scrollTo just now, but i couldnt get a good calculation of it and it wasn't working out accurately. Keep in mind this isn't finalized code so its not too pretty, but it would be something along these lines i'd imagine. i'm not math genius by any means so this may be a bit beyond me.
Yeah I am not a math genius either (-: But anyway it seems very workable, but yeah needs some further attention perhaps. It seems to get close to the numbers input, dead on on some and close +/- on others. For example:
scrollTo1_Btn.onPress = function():Void {
scroller.scrollTo(0);
trace(this + " scrollTo(0)")
// Trace = _level0.scrollTo_1Btn scrollTo(0) , returns 0
};
scrollTo2_Btn.onPress = function():Void {
scroller.scrollTo(500);
trace(this + " scrollTo(500)")
// Trace = _level0.scrollTo_2Btn scrollTo(500) , returns -490
};
scrollTo3_Btn.onPress = function():Void {
scroller.scrollTo(1000);
trace(this + " scrollTo(1000)")
// Trace = _level0.scrollTo_3Btn scrollTo(1000) , returns -675, -934, -1001
};
scrollTo4_Btn.onPress = function():Void {
scroller.scrollTo(content_mc.movie_mc._height-300);
trace(this + " scrollTo " + content_mc.movie_mc._height)
// Trace = _level0.scrollTo_4Btn scrollTo 2000.1 , returns -1627 , -1700
};
For the scrollTo_4Btn I compensated -300 so if you press mutiple your always at the bottom position because if you go the full amount scroller.scrollTo(2000) in my testing, then repeated presses of that button cause things to jump and repeat and not remain flush at the bottom, thus the compensation.
Again seems doable/workable but of course can be enhanced etc... but nice job mprzybylski, thanks for the scrollTo update, I will be curious if you mess with it further. I may look at it more closely tomorrow and play with it more.
Maybe a math whiz will stop by :thumb:
mprzybylski
November 1st, 2007, 02:24 AM
I think the issue is with the rounding of the percentage value (or not rounding i should say) and how it then carries over to the scroller positioning. The whole movement revolves around moving the actual scroller and then everything else moves with it because of the way the scroller is built, so you have to have a fairly accurate algorithm to calculate the input to the scrollTo() method, but the problem is that the scrollTo method you want to be able to scroll the content to a certain value, NOT the scroller because that wouldnt make much sense. So the math to translate the pixels to scroll the content to then control the scroller to move it into the proper position for the content to actually end up at the input value is what trips me up.
i don't know if any of that makes sense, if not i can try to explain it better.
prg9
November 1st, 2007, 09:41 AM
The whole movement revolves around moving the actual scroller and then everything else moves with it because of the way the scroller is built....... So the math to translate the pixels to scroll the content to then control the scroller to move it into the proper position for the content to actually end up at the input value is what trips me up......... i don't know if any of that makes sense, if not i can try to explain it better.
Yeah that makes sense and is confusing at the same time :crazy:
Would maybe be easier math to base it on the scroller._height and percentages from that, 0 being top, 100 being bottom, 50 being middle and so on, but then the developer would have to do some simple math to know the content they wish to scrollTo is at 750 so they would enter 75 to scrollTo that position. But then if there content is 1486 in height then it becomes cumbersome to try to do it this way.
Thus I see what your trying to do, and it works for the most part from what I have seen, definitely workable.
vini
November 1st, 2007, 11:52 AM
Nice One
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.