Search code examples
actionscript-3flashapache-flexairflex4.5

Adobe Air: WindowedApplication


I am a beginner. I have developed a desktop application using Adobe Air Flash Builder. I am using a WindowedApplication Container that serves as the entry point for the Flex Application.

The problem: I have a button whose event handler redirects me to a new window using the the addElement and NavigatorContent property. Here's the handler:

        public function startstudy_clickHandler(event:MouseEvent):void
        {
            var dTracker:Study = new Study();
            this.addElement(dTracker);
        }

Here's the NavigatorContent code:

        <s:NavigatorContent width="100%" height="100%" label="PRACTICE" icon="@Embed(source='assets/image.png')" toolTip="PRACTICE" id="navprac">

What's happening is that when I am redirected to the new window, the dimensions of the new window are not the same as those of the WindowedApplication. Infact, no matter whether I resize the WindowedApplication before clicking the button, the new window has the same exact dimensions everytime. I need the new window to be of the same size as the calling (WindowedApplication) window.

Is there a way around this? If not, then how can I make all the windows to be the same size from the start,that is, disable their resizing and set all windows to the size of the screen.


Solution

  • Judging by your comments above, Study is of type Window in which case, when you invoke new Study() you are creating a new window. This window has a completely different set of height and width the the first window created when the WindowedApplication started.

    To get around this you could explicitly state these properties:

    var dTracker:Study = new Study();
    dTracker.height = this.height;
    dTracker.width = this.width;
    dTracker.x = this.x;
    dTracker.y = this.y;
    

    Or you could change Study from being a window to something like Group or Panel, this would then add it to the current window rather than creating a new one