3 Replies Latest reply on Jun 12, 2007 5:20 PM by sasha magee

    Trouble with NativeWindow

    kmintmier
      Hello everyone. I'm trying to prevent a user from maximizing the Flash Player window. I've just installed the Flex Builder 3 beta thinking that I could use the features associated with the NativeWindow class. I tried creating a new ActionScript Project using the Moxie SDK and entered this line in an appropriate place:

      import flash.display.NativeWindow;

      When Flex Builder 3 builds the project, I get this error:

      1172: Definition flash.display:NativeWindow could not be found.

      Any thoughts on this? Could I have messed up the installation or am I trying to do the wrong thing? At a higher level, is there a better way to disable the maximize button?

      Once I've got that working, I'd also like to find out if it's possible to capture clicks of the Flash player's "close" button. Specifically, I want to ask the user if they really want to exit the program.

      Thanks in advance to anyone that can help me get on the right track.
        • 1. Re: Trouble with NativeWindow
          sasha magee Level 2
          The error you're seeing makes me believe you're not working in an AIR project. Specifically, you do not have airglobal.swc in your library path.

          To create an ActionScript project destined for AIR, you need to:
          1. Select File->New->AIR Project.
          2. in the New Project Wizard, get to the screen that specifies your main file name (which will be projectName.mxml)
          3. Rename the file to projectName.as
          4. Click Finish.
          (yes, it's a little weird. We're working on it).

          If you are, in fact, working in an AIR project, you can capture the close button click by listening for the "closing" event.
          • 2. Trouble with NativeWindow
            kmintmier Level 1
            Thanks so much, Sasha. I've gotten a bit farther. I've added this line:

            var n:NativeWindow = new NativeWindow(true, new NativeWindowInitOptions());

            The SFW still builds, but when I run/open it, I get this runtime error:

            VerifyError: Error #1014: Class flash.display::NativeWindow could not be found.
            at [verify]
            at [verify]
            at TestProject()
            at [execute-queued]


            I'm sure I'm just missing a piece of the big picture here. Maybe that isn't how you're supposed to run an AIR-based SWF?

            Thanks again.
            • 3. Re: Trouble with NativeWindow
              sasha magee Level 2
              Right. So the way to run an AIR swf is to pass the AIR runtime the XML file that defines your application.

              It sounds like you are trying to run a SWF compiled for AIR in the regular Flash Player runtime, which won't work. SWFs compiled for the AIR runtime will only run in that runtime.

              Have you downloaded the AIR beta? It should have some example projects for you. However, you can try this all out in Flex Builder by creating a new AIR project as I described above.

              One caveat is that we have not yet implemented the ability to prevent maximizing the initial AIR window, so what you're trying will require that you do create a secondary window. See the Labs Wiki for an example.