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

Posts: 167
Registered: ‎12-17-2010
My Device: Bold 9000
My Carrier: Vodafone

stage.stageWidth and stage.stageHeight unknown in class file

I want to use stage.stageWidth and stage.stageHeight in a subclass, but I get the error message "Error #1009: Cannot access a property or method of a null object reference."

How can I solve this?


My PlayBook App: Checklists
Posts: 1,280
Registered: ‎03-03-2011
My Device: Playbook, Z10, Q10, Z30 with Files & Folders and Orbit of course
My Carrier: Vodafone

Re: stage.stageWidth and stage.stageHeight unknown in class file

[ Edited ]

You cannot access the stage until the component has been added to the display stack with addChild(). When that happens, the component receives  an addedToStage event, and you can start using the stage property. Bear in mind that elegant code does not rely on such things. You may later decide to add your component into a different container, with different dimensions. Creating such a dependancy to stage is often considered bad form.

Files & Folders, the unified file & cloud manager for PlayBook and BB10 with SkyDrive, SugarSync, Box, Dropbox, Google Drive, Google Docs. Free 3-day trial! - Jon Webb - Innovatology - Utrecht, Netherlands
Posts: 172
Registered: ‎01-17-2011
My Device: 9500 series
My Carrier: Airtel

Re: stage.stageWidth and stage.stageHeight unknown in class file


Once components are added to your screen , than you can use stage variable.

To do soo , in initialize method add a listener Event.ADDED_TO_STAGE , on its listener you can access stage variable.

I hope this can help you.