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
Trusted Contributor
wmatt
Posts: 107
Registered: ‎10-02-2011
My Carrier: none
Accepted Solution

Scrolling Container

I want a simple vertical scrolling space where I can place images and other things. I tried using the fuse container class, but the code below doesn't scroll. Do I need to add a layout? Is the old ScrollPane class better for this?

 

import flash.display.Sprite;
import flash.events.Event;

import qnx.fuse.ui.core.Container;
import qnx.fuse.ui.listClasses.ScrollDirection;
import qnx.ui.display.Image;

[SWF(height="600", width="1024", frameRate="30")]
public class ContainerDemo extends Sprite
{
	private var container:Container;
	private var image:Image;
	
	public function ContainerDemo()
	{
		super();
		//create container
		container = new Container();
		container.scrollDirection = ScrollDirection.VERTICAL;
		container.height = stage.stageHeight;
		container.width = stage.stageWidth;
		container.vScrollVisible = true;
		container.allowScrollPastEdge = true;
		//create image
		image = new Image();
		image.addEventListener(Event.COMPLETE, onImageLoaded);
		image.setImage("http://farm8.staticflickr.com/7174/6787853901_bd49c6d82d_o.jpg");
		//add container to stage
		this.addChild(container);	
	}
	
	protected function onImageLoaded(event:Event):void
	{
		//add image to container
		container.addChild(image);
	}
}

 

Please use plain text.
Trusted Contributor
wmatt
Posts: 107
Registered: ‎10-02-2011
My Carrier: none

Re: Scrolling Container

Anyone have some quick pointers on doing this? I think if I can figure out this simple example it will help me in understanding the containers.

 

Also, there seems to be some javascript errors preventing this documentation from showing inherited methods and properties.

Please use plain text.
Developer
jtegen
Posts: 6,529
Registered: ‎10-27-2010
My Carrier: Verizon

Re: Scrolling Container

You have to use a ScrollPane. Add your container to the ScrollPane. There are lots of samples on the forum that discusses this. If you get stuck, post the new code for help.
Please use plain text.
Trusted Contributor
wmatt
Posts: 107
Registered: ‎10-02-2011
My Carrier: none

Re: Scrolling Container

The documentation says the fuse container includes scroll support. That's why I'm thinking I don't need the scroll pane. But this code isn't working.

 

import flash.display.Sprite;
import flash.events.Event;

import qnx.fuse.ui.core.Container;
import qnx.fuse.ui.display.Image;
import qnx.fuse.ui.events.ScrollEvent;
import qnx.fuse.ui.listClasses.ScrollDirection;

[SWF(height="600", width="1024", frameRate="30")]
public class ContainerDemo extends Sprite
{
	private var container:Container;
	private var image:Image;
	
	public function ContainerDemo()
	{
		super();
		//create container
		container = new Container();
		container.scrollDirection = ScrollDirection.VERTICAL;
		container.height = stage.stageHeight;
		container.width = stage.stageWidth;
		container.vScrollVisible = true;
		container.allowScrollPastEdge = true;
		//create image
		image = new Image();
		image.addEventListener(Event.COMPLETE, onImageLoaded);
		image.setImage("http://farm8.staticflickr.com/7174/6787853901_bd49c6d82d_o.jpg");
		//add container to stage
		this.addChild(container);
		//listen for scrolling
		container.addEventListener(ScrollEvent.SCROLL_BEGIN, onScrollBegin);
		container.addEventListener(ScrollEvent.SCROLL_MOVE, onScrollMove);
		container.addEventListener(ScrollEvent.SCROLL_END, onScrollEnd);
	}
	
	protected function onScrollEnd(event:Event):void
	{
		trace("scroll end");
	}
	
	protected function onScrollMove(event:ScrollEvent):void
	{
		trace("scroll move");
	}
	
	protected function onScrollBegin(event:ScrollEvent):void
	{
		trace("scroll begin");
	}
	
	protected function onImageLoaded(event:Event):void
	{
		//add image to container
		container.addChild(image);
	}
}

 

Please use plain text.
Developer
jtegen
Posts: 6,529
Registered: ‎10-27-2010
My Carrier: Verizon

Re: Scrolling Container

Here's an old thread.  Anyone ever get the fuse container to scroll?  Finally converting over to it for BB10, but there are no practical examples to scroll something simple.  I have a UIComponent that I want to scroll (think chart), and it just sits there.

 

Please RIM, add examples to all the classes that show basic and advanced features.

Please use plain text.
Developer
dbigham
Posts: 417
Registered: ‎04-01-2009
My Carrier: NA

Re: Scrolling Container

Please use plain text.
Developer
dbigham
Posts: 417
Registered: ‎04-01-2009
My Carrier: NA

Re: Scrolling Container

Scrolling is working for me now.

 

The problem was that my "Container" object was given the height of the stage, so even though it exceeded the visible height (defined by the presence of an ActionBar), there was nothing to scroll.

 

The solution was to resize the Container to be the height of the stage minus the height of the ActionBar.

Please use plain text.
Developer
dbigham
Posts: 417
Registered: ‎04-01-2009
My Carrier: NA

Re: Scrolling Container

I had got this to work by using a StackLayout in conjunction with a Container, but then I realized that StackLayout is different than the Cascades StackLayout and so switched to using RowLayout. But RowLayout isn't working for me since it seems to resize labels to be a single line in height.

 

So I stopped using the Layout controls and went back to manually positioning Label controls in a Container, and now scrolling isn't working. Perhaps this is what others are finding as well?

Please use plain text.
Trusted Contributor
georg22
Posts: 231
Registered: ‎11-22-2011
My Carrier: vodafone

Re: Scrolling Container

I ran into the same problem.

I tried to use a StackLayout with a Container - but nothing too. Maybe i did something wrong.

Has someone a working example?

Please use plain text.
Developer
jtegen
Posts: 6,529
Registered: ‎10-27-2010
My Carrier: Verizon

Re: Scrolling Container

I have asked RIM for better samples, but have yet to hear back. I've tried many hours to get their class to work.
Please use plain text.