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
Highlighted
Contributor
Posts: 27
Registered: ‎03-31-2011
My Device: Developer
My Carrier: Developer
Accepted Solution

Cant Add Container to 2nd Sprite

Is there a way to add UIComponents to a sprite separate from the main sprite?

 

for example, I have  popup which is just a sprite added ontop of the sprite from the stage.

 

I don't get any errors, it just pretends that they are not there. Here is some code for an example:

package
{
	import flash.display.Sprite;
	import qnx.ui.core.*;

	[SWF(height="600", width="1024", frameRate="30", backgroundColor="#FFFFFF")]
	public class Example extends Sprite
	{
		public function Example()
		{
			
			super();
			//put in a popup
			this.addChild(new popup());
			
		}
	}
}

 

 

package
{
	import flash.display.Shape;
	import flash.display.Sprite;
	
	import qnx.ui.core.*;
	
	public class popup extends Sprite {
		public function popup(){
			
			super();
			
			// make a background for the popup
			var shape:Shape;
			shape = new Shape();
			shape.graphics.beginFill(0x000000,0.9);
			shape.graphics.drawRect(0,0,600,300);
			shape.graphics.endFill();
			this.addChild(shape);
			
			//add a container to the popup
			var myMain:Container = new Container();
			myMain.margins = Vector.<Number>([50,60,50,60]);
			myMain.flow = ContainerFlow.HORIZONTAL;
			myMain.debugColor = 0xFFCC00;
			
			this.addChild(myMain);
		}
	}
	
}

 

Check out Go Studio on Blackberry App World!

http://appworld.blackberry.com/webstore/content/38912
Developer
Posts: 146
Registered: ‎03-27-2011
My Device: Blackberry Playbook
My Carrier: WiFi

Re: Cant Add Container to 2nd Sprite

I'll take a look at your code when I'm not on my mobile, but does your container render as you'd expect if you add it directly instead of as a child of the sprite?
----------------------------------------
If this post solved your problem, please click the 'Accept as Solution' button.
If you found this post useful, please provide a Kudo. Thanks.

Approved Apps: Celestial Slingshot
Contributor
Posts: 27
Registered: ‎03-31-2011
My Device: Developer
My Carrier: Developer

Re: Cant Add Container to 2nd Sprite

I can add it to the main sprite but the background of the second sprite draws, just no container.

Check out Go Studio on Blackberry App World!

http://appworld.blackberry.com/webstore/content/38912
Developer
Posts: 386
Registered: ‎12-12-2010
My Device: BB Style
My Carrier: Sprint

Re: Cant Add Container to 2nd Sprite

check your blackberry-tablet.xml has this:  <transparent>false</transparent>

 

If its true you will see wierd things like transparent container or no container.

Developer
Posts: 345
Registered: ‎03-13-2011
My Device: Playbook
My Carrier: n/a

Re: Cant Add Container to 2nd Sprite

[ Edited ]

call me crazy (and I may be as I am very new to the actionscript stuff) but dont you need to set the width and height of the inner sprite? Or you could draw directly on the inner sprite not using the child shape

Developer
Posts: 146
Registered: ‎03-27-2011
My Device: Blackberry Playbook
My Carrier: WiFi

Re: Cant Add Container to 2nd Sprite

The width and height of the inner sprite should change according to the size of it's children.
----------------------------------------
If this post solved your problem, please click the 'Accept as Solution' button.
If you found this post useful, please provide a Kudo. Thanks.

Approved Apps: Celestial Slingshot
Developer
Posts: 345
Registered: ‎03-13-2011
My Device: Playbook
My Carrier: n/a

Re: Cant Add Container to 2nd Sprite

 


Brandon_Appetizer wrote:
The width and height of the inner sprite should change according to the size of it's children.

I wasn't sure because I thought I had an issue where this was happening to me and I fixed it by setting the width. I am pretty sure you are right though because as I said I am new to the whole actionscript/flash thing. Thanks for letting me know

 

Developer
Developer
Posts: 1,123
Registered: ‎02-10-2009
My Device: 8130 / 8350 / 9530 / 9550 / 9850 / PlayBook
My Carrier: Verizon

Re: Cant Add Container to 2nd Sprite

You didn't place your container by setting the x and y. By default it will place it after your shape which is outside the viewing area of your popup.

Contributor
Posts: 27
Registered: ‎03-31-2011
My Device: Developer
My Carrier: Developer

Re: Cant Add Container to 2nd Sprite

I tried that. It doesnt use the container but now I can move around stuff inside the container...So it does half of what I want it to do

Check out Go Studio on Blackberry App World!

http://appworld.blackberry.com/webstore/content/38912
Developer
Posts: 165
Registered: ‎10-26-2010
My Device: BlackBerry® PlayBook™
My Carrier: .

Re: Cant Add Container to 2nd Sprite

At the end of your popup code add:

 

 

myMain.setSize(600, 300);

 

 

to force the layout to refresh and your container will show up.

 

Default x and y are 0, so they do not need to be set unless you need to change the position.