Good afternoon,
I am creating a android app using adobe air (flex sdk 4.6.0) and i am trying to find out what the width of the phone screen is in pixels. So I am fallowing the tutorial here but when ever i copy the code into my project and click run it always gives me this error "TypeError: Error #1009: Cannot access a property or method of a null object reference." and goes to the line that has stage.stageWidth I have also tried stage.width but it does the same thing. So does stage.stageWidth no longer work or how do you tell the screen size of the tablet or phone? Was it replaced with something else for phones? I am trying to get the information so i can center images in the center of the screen using action script.
protected function init():void {
//function run at creationComplete="init()"
movePhotoToCenter(myIMG1);
// trying to get the stage width so that i can center a img that is allready added to the flex code and has a id of "myIMG1"
}
protected function movePhotoToCenter(img:Image):void {
//"error here" where im centering the image
var centerOfStage:Number = stage.stageWidth/2;
var Xnumber:Number = centerOfStage - (img.width/2);
trace(Xnumber);
var move:Move = new Move(img);
move.xFrom = img.x;
move.xTo = Xnumber;
move.yFrom = img.y;
move.yTo = img.y;
move.duration = 3000;
move.play();
trace(img.width);
img.scaleX=1;
img.scaleY=1;
trace(img.width);
}
Thanks for you help, Justin