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
Retired
dmalik
Posts: 427
Registered: ‎02-22-2012
My Device: BlackBerry Z10, BlackBerry Dev Alpha C, BlackBerry PlayBook

For dbigham - Scrolling label sample

Hey,

 

Here is a sample from our discussion at the portathon.

 

package
{
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageOrientation;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	
	import qnx.fuse.ui.core.Container;
	import qnx.fuse.ui.layouts.gridLayout.GridLayout;
	import qnx.fuse.ui.listClasses.ScrollDirection;
	import qnx.fuse.ui.text.Label;
	import qnx.fuse.ui.text.TextBase;
	import qnx.fuse.ui.text.TextFormat;
	import qnx.fuse.ui.layouts.Align;
	
	[SWF(frameRate="60", backgroundColor="#FFFFAA")]
	public class DisplayTest extends Sprite
	{
		private var container:Container;
		
		public function DisplayTest()
		{
			
			stage.align = StageAlign.TOP_LEFT;
			stage.scaleMode = StageScaleMode.NO_SCALE;
			addEventListener(Event.ADDED_TO_STAGE,handleAddedToStage);
			
		}
		
		private function handleAddedToStage(e:Event):void
		{
			doStuff();
			removeEventListener(Event.ADDED_TO_STAGE,handleAddedToStage);
			
			// stage is avail, we can now listen for events
			stage.addEventListener( Event.RESIZE, onResize );
			
			// force a resize call
			onResize(new Event(Event.RESIZE));
		}
		
		private function doStuff():void{
			//create container
			container = new Container();
			container.scrollDirection = ScrollDirection.VERTICAL;
			container.height = stage.stageHeight;
			container.width = stage.stageWidth;
			container.hScrollVisible = false;
			container.vScrollVisible = true;
			container.allowScrollPastEdge = false;
			
			//create layout
			var layout:GridLayout = new GridLayout();
			container.layout = layout;
			layout.paddingRight = 50;
			layout.paddingLeft = 50;
			layout.paddingTop = 200;
			layout.paddingBottom = 200;
			layout.vAlign = Align.BEGIN;
			layout.hAlign = Align.FILL;

			//Create Label
			var myLabel:Label = new Label;
			myLabel.text = "This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - This is some long text - ";
			myLabel.maxLines = 0;
			container.addChild(myLabel);

			//add container to stage
			this.addChild(container);
		}
		
		private function onResize(event:Event):void
		{
			
			//portrait
			if ( stage.stageHeight > stage.stageWidth ) {
				
				trace("portrait mode");
				container.width = stage.stageWidth;
				container.height = stage.stageHeight;
				
				
				//landscape
			}else{
				trace("landscape mode");
				container.width = stage.stageWidth;
				container.height = stage.stageHeight;
				
			}
			
		}
	}
}

 

Follow me on Twitter: @dustinmalik
-----------------------------------------------------------------------------------------------------
Keep up to date on BlackBerry development: http://devblog.blackberry.com/
Please use plain text.