01-28-2011 06:15 AM
Hi all.
Is there a way,when you set the scrollx, to move the scrollPane at the position x from t position you were scrolling until you reach x?
Sorry for my english,maybe i don't explain very well.
Solved! Go to Solution.
01-29-2011 11:15 AM
Are you asking for a type of animation, where the ScrollPane changes over a period of time rather than just jumping to the specified position?
(If that's what you want, do you know about caurina.transitions.Tweener?)
01-29-2011 02:29 PM
I'm pretty sure that's what he's looking for. Right now when you set scrollX and scrollY in a ScrollPane it abruptly snaps directly to the position. It would be nice to animate that but I highly doubt caurina transitions would do the trick.
01-29-2011 04:12 PM - edited 01-29-2011 04:38 PM
The only way I can think to do this would be to use a custom helper object - like a tracking point or pixel that could be tweened by Tweener. During the tween, scrollX and scrollY of the ScrollPane would need to be updated to match the x and y position of the tracking point with something like...
function animateScroll(finalX:Number, finalY:Number, t:Number = 0.25):void
{
var trackingPoint:Point = new Point(scrollPane.scrollX,scrollPane.scrollY);
Tweener.addTween(trackingPoint, {
time: t,
x: finalX,
y: finalY,
onUpdate: function():void {
scrollPane.scrollX = trackingPoint.x;
scrollPane.scrollY = trackingPoint.y;
},
onComplete: function():void {
trackingPoint = null;
}
});
}
//For usage:
animateScroll(59,827);
This is definitely pseudo-code and may not work "out of the box." I haven't tested it, but the concept should work. You will likely want to account for min and max scroll values and perhaps scroll direction.
You may even be able to tween the scrollX and scrollY directly. Tweener tweens numeric properties of the object passed in, and scrollX and scrollY are numeric properties.
01-29-2011 11:23 PM
studiochris wrote:You may even be able to tween the scrollX and scrollY directly. Tweener tweens numeric properties of the object passed in, and scrollX and scrollY are numeric properties.
This was my assumption. I can't see any reason you can't tween an arbitrary numeric parameter on an arbitrary object, so Tweener.addTween(myscrollpane, {scrollX: newpos, time: 1, transition: 'linear'}); should work.
01-30-2011 12:23 AM
01-31-2011 03:43 AM - edited 01-31-2011 03:44 AM
thank you very much,that's what i was searching for.Tested and it works ![]()
02-02-2011 12:50 PM
Has anyone gotten this to actually work? I have a ScrollPane and I explicitly set the scrollY value to something other than the current value (but still in range of 0 - max height) and the contents does not move. I've tried calling update() after it, and that did nothing.
02-02-2011 01:06 PM - edited 02-02-2011 01:10 PM
I got it working already. I center the scrollpane during the startup, let me see if I can find my code around here somewhere.
EDIT: found it!
private var scroller:ScrollPane; ... scroller.scrollX = rootElement.x + rootElement.width/2 - scroller.width/2; scroller.scrollY = rootElement.y + rootElement.height/2 - scroller.height/2;
As you can see, no special gizmo's here I'm afraid. Are you absolutely certain you are setting it to the correct value?
02-02-2011 02:13 PM
taylortbb wrote:
I haven't tested specifically for ScrollPane, but peter9477 is correct that Tweener will change any numeric value on any object. You can tween opacity, location, size, zoom, etc.
As long as scrollX isn't write-only Tweener should work fine.
I never thought to try this but have been wondering for a while now if it's possible to make things appear and disappear, or change size or anything quite frankly. Thanks!