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
New Developer
Posts: 6
Registered: ‎02-21-2013
My Device: Z10
My Carrier: Rogers
Accepted Solution

Screen origin not 0,0 ?

Hi ,  I am drawing some sprites onto the main stage but when I add them and set their x,y to 0,0  they are not in the upper left of the device screen.

 

Does anyone know what might be causing this issue?    It is as though the stage origin is offset by a couple hundred pixels

 

eg..

var mySprite:Sprite = new Sprite();  

mySprite.graphics.beginFill(0x336699); 

mySprite.graphics.drawRect(0,0,200,200); 

mySprite.x=0;

mySprite.y=0; 

addChild(mySprite);

 

 

Highlighted
Developer
Posts: 172
Registered: ‎01-17-2011
My Device: 9500 series
My Carrier: Airtel

Re: Screen origin not 0,0 ?

Hi , 

You need to align your stage for that use

addEventListener(Event.ADDED_TO_STAGE , onAdded ) ;
private function onAdded(e : Event) : void
{
	stage.align = StageAlign.TOP_LEFT;
	stage.scaleMode = StageScaleMode.NO_SCALE;
	
        var mySprite:Sprite = new Sprite();  
        mySprite.graphics.beginFill(0x336699); 
        mySprite.graphics.drawRect(0,0,200,200); 
        mySprite.x=0;
        mySprite.y=0; 
        addChild(mySprite);
}

 I hope it should work.

New Developer
Posts: 6
Registered: ‎02-21-2013
My Device: Z10
My Carrier: Rogers

Re: Screen origin not 0,0 ?

Awesome, thx!