03-31-2011 09:18 PM
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);
}
}
}
Solved! Go to Solution.
03-31-2011 10:40 PM
03-31-2011 10:42 PM
I can add it to the main sprite but the background of the second sprite draws, just no container.
03-31-2011 10:45 PM
check your blackberry-tablet.xml has this: <transparent>false</transparent>
If its true you will see wierd things like transparent container or no container.
03-31-2011 10:46 PM - edited 03-31-2011 10:48 PM
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
03-31-2011 10:53 PM
03-31-2011 10:59 PM
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
03-31-2011 11:44 PM
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.
04-01-2011 12:32 AM
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
04-01-2011 10:51 AM
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.