It's probably null because the stage isn't available yet. Try doing it in your "application complete" handler.
--- In flexcoders@yahoogroups.com, "Wesley Acheson" <wesley.ache...@...> wrote: > > On Mon, Jan 12, 2009 at 9:48 PM, Wally Kolcz <wko...@...> wrote: > > > This is probably a dumb question but... > > > > I am trying to do a Flex app primarily in AS. In the constuctor I am trying > > to create an ApplicationControlBar that is the same as this: > > <mx:ApplicationControlBar right="5" left="5" top="55" id="mainACB" /> > > > > I am having a problem with trying to create the same effect as right="5" > > and left="5". I assume that I need to put the x="5" (hence the left="5") and > > then do the math to find out the 'stage' size and subtract the other side > > (5) for the width. However what do I use to do the math? > > > > I tried Application.application.stage.width, but I keeping getting a null > > value error. How can I detect the size of the swf at 100%x100% and do the > > math or is there an easier way to do this. Didn't see a mainACB.right. > > > > Here is what I do have: > > > > var mainACB:ApplicationControlBar = new ApplicationControlBar(); > > mainACB.x = 5; > > mainACB.y = 65; > > mainACB.height = 30; > > mainACB.width = Application.application.stage.width - 5; > > Application.application.addChild(mainACB); > > > > > > Em can you not just add mainABC.setStyle("right","5") or am I missing > something? I think that this is what you want? > > Regards, > Wesley >