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
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Inserting a photo album

You shouldnt have to copy the array out.  Have you looked at using:

 

var nbr  : int = this._list.dataProvider.length;
var i    : int;
var node : Object;
for( i=0; i < nbr; i++ )
{
	node = this._list.dataProvider.getItemAt( i );
	// edit node parameter here
	this._list.dataProvider.replaceItemAt( node, i );
}

 

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

Re: Inserting a photo album

Thanks that works as well -- and even better all in one loop through.

Please use plain text.
Developer
jffurlan
Posts: 1,003
Registered: ‎01-16-2011
My Device: PlayBook (sim)
My Carrier: Rogers

Re: Inserting a photo album

[ Edited ]

Really don't want to start a new thread for this:

 

Any tips on why the objects won't align in the middle of my container (sometimes they do horizontally, but always at the top).

 

 

            album = new Container();
            album.margins = Vector.<Number>([7.5,7.5,7.5,7.5]);
            album.setPosition(15,15);
            album.setSize(994,285);
            album.graphics.beginFill(0x333333, 1);
            album.graphics.drawRect(0,0,994,285);
            album.flow = ContainerFlow.VERTICAL;
            album.align = ContainerAlign.MID;
            pictures.addChild(album);


            images = new Image();
            images.setImage("assets/pics/img1.png");
            album.addChild(images);
       

 

and another example


            navCont = new Container();
            navCont.setSize(1024,123);
            navCont.flow = ContainerFlow.VERTICAL;
            navCont.align = ContainerAlign.MID;
            this.y = -123;
            addChild(navCont);

navLabel = new Label(); navLabel.setSize(1024,123); navLabel.text = ("App Title"); navCont.addChild(navLabel);

 

 

- 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.
Developer
studiochris
Posts: 165
Registered: ‎10-26-2010
My Device: BlackBerry® PlayBook™
My Carrier: .

Re: Inserting a photo album

[ Edited ]

According to the documentation, or at least my understanding of it, Container alignment only goes in one direction, with that one direction being opposite the direction of your flow.

 

To use your layout as an example, your container flows vertically, so alignment options would work horizontally, which is why you see your image centered horizontally. To make something align to the middle vertically, it would need to flow horizontally.

 

Outside of the container class, here's one way how do middle center alignment (it assumes the transform points for the objects are top-left):

 

 

//Your image or the child object
var image:Image;

/* Using a Sprite for the parent container in the example, 
 * but you could also use the
 * Container class for this. Just make sure its layout is complete 
 * before you try to use x, y, z, width and height - other wise, they 
 * are all 0 or wrong.
*/

var container:Sprite;

...

container.addChild( image );

container.setSize(100,100);

image.x = ( container.width - image.width ) / 2;
image.y = ( container.height - image.height ) / 2;

 

To make it easier, if you're going to use it over and over, maybe you could encapsulate it in a helper function that looks something like:

 

 

function centerThis(item:DisplayObject, container:DisplayObject):void
{
     item.x = ( container.width - item.width ) / 2;
     item.y = ( container.height - item.height ) / 2;
}

 

 

Then, you'd just call that function when something needed to be centered.

 

 

centerThis(image, container);

 

 

Please use plain text.
Developer
jffurlan
Posts: 1,003
Registered: ‎01-16-2011
My Device: PlayBook (sim)
My Carrier: Rogers

Re: Inserting a photo album

Thanks. I had tried that earlier and it hadn't worked so I gave up on it. Trying againg though I guess I did something wrong originally.

- 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.