4 Replies Latest reply on Apr 22, 2008 4:11 AM by zacko_2

    Multiple Screens and Variables?

    zacko_2 Level 1
      Is there a way/place to store variables so that other screens can write and read the variables?

      Essentially I am building an HTML/JS app that has multiple pages and I am assuming screens are the way to go. Am I approaching this wrong? Is there a better way to have information persist and use multiple pages?

      Thanks!
        • 1. Re: Multiple Screens and Variables?
          Joe ... Ward Level 4
          (By screens, I assume you mean windows -- AIR uses the term screen to represent a desktop screen/monitor).

          Yes. As long as the content of a window or frame is in the same security sandbox AND you have a reference to an object in the other window, you can access that object. In AIR this works the same as it would in a typical browser.

          (The only caveat being that if you use the createRootWindow() function rather than the window.open() function to create a window, the opener and parent properties of the created window aren't automatically set.)
          • 2. Multiple Screens and Variables?
            zacko_2 Level 1
            Okay, maybe I misunderstood the whole screen thing based on the tutorials in the developing AIR with HTML and JavaScript ( http://livedocs.adobe.com/air/1/devappshtml/). It seemed to me that I could have hidden screens and move them so that they showed in the main monitor? No biggie.

            Here is what I need: I have an HTML file (index.html). It has menu buttons at the top, if someone goes to a new page via an <a href="... " (call it about.html), how do I bring my variables or get the data from the previous page to this page? Is there a place to store variables so that they can be made available? Is this a JavaScript thing, or is this an AIR thing? Also, launching a new window is not what I want to do. When you say 'object', what kind of object are you talking about? Is it a generic Object created by ActionScript? Do I subclass this object to hold my variables and values? Kind of like a session variable or other scope of variable where I can access the information and change it no matter what HTML file the system is using.

            Sorry, I know that was long!

            Thanks.
            • 3. Re: Multiple Screens and Variables?
              Joe ... Ward Level 4
              You would do it the same way as you would in a browser -- so its a JavaScript thing.

              For example, your main application file (i.e. index.html) could use frames so that the main page is never unloaded. Thus you would save your session variables in the parent frame and make sure that only the child frames ever "navigated" to a new page. The loaded pages would then access the parent to load/save any data.

              When I say object I mean pretty much any JavaScript construct such as a variable, function, built-in object like "Window" or a custom object that you create.
              • 4. Re: Multiple Screens and Variables?
                zacko_2 Level 1
                Alright, that makes sense. I will try that and see where it gets me. Thanks for your help and advice. It's funny, I've spent all this time on the web avoiding frames, and yet, here I am using frames :)

                Thanks!