Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Reply
Contributor
Badge
Posts: 16
Registered: ‎01-04-2011
My Device: Not Specified
My Carrier: Java Developer
Accepted Solution

ScrollPane scrollX in movement

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.

Please use plain text.
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: ScrollPane scrollX in movement

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?)


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Please use plain text.
Contributor
vinng86
Posts: 22
Registered: ‎01-14-2011
My Device: Blackberry Storm

Re: ScrollPane scrollX in movement

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.

Please use plain text.
Developer
studiochris
Posts: 165
Registered: ‎10-26-2010
My Device: BlackBerry® PlayBook™
My Carrier: .

Re: ScrollPane scrollX in movement

[ Edited ]

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.

Please use plain text.
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: ScrollPane scrollX in movement

 


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.

 


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Please use plain text.
Developer
taylortbb
Posts: 137
Registered: ‎10-26-2010
My Device: Bold 9900 + PlayBook
My Carrier: Rogers

Re: ScrollPane scrollX in movement

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.
--------
Taylor Byrnes
Please use plain text.
Contributor
Badge
Posts: 16
Registered: ‎01-04-2011
My Device: Not Specified
My Carrier: Java Developer

Re: ScrollPane scrollX in movement

[ Edited ]

thank you very much,that's what i was searching for.Tested and it works :smileyhappy:

Please use plain text.
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: ScrollPane scrollX in movement

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.

Please use plain text.
Developer
zezke
Posts: 1,004
Registered: ‎12-12-2010
My Device: Z10 (red Limited Edition)
My Carrier: Mobile Vikings

Re: ScrollPane scrollX in movement

[ Edited ]

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?

-------------------------------------------
BlackBerry Certified Builder for Native Application Development -- Proud member of the Belgian BlackBerry Developer group
Samples: Park in Ghent
Feeling generous? Nominate me for BB Elite member!
Please use plain text.
Developer
jffurlan
Posts: 1,003
Registered: ‎01-16-2011
My Device: PlayBook (sim)
My Carrier: Rogers

Re: ScrollPane scrollX in movement

 


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!

 

- If you like my response/post, or it helped you find an answer you were looking for, please provide a Kudo - white star to the bottom right of this post. -
- Please use the search bar at the top, or check out the PlayBook FAQ's for help getting started -
- Hockey DrillBook -
Please use plain text.