2 Replies Latest reply on Aug 28, 2008 7:13 AM by nvahalik

    Adding a custom variable to HTMLLoader

    nvahalik
      Perhaps I am doing this wrong, but I'm generating an HTMLLoader window like so:

      quote:

      nwio = new air.NativeWindowInitOptions();
      nwio.systemChrome = runtime.flash.display.NativeWindowSystemChrome.NONE

      var bounds = new air.Rectangle(a.bounds.x,
      a.bounds.y,
      a.bounds.width,
      a.bounds.height);

      var htmlControl = air.HTMLLoader.createRootWindow(true, nwio, false, bounds);


      I want to attach a variable to this object, but every time I put a variable on it, I get this message:

      quote:

      app:/main.html][21:43:26] ReferenceError: Error #1056: Cannot create property screenIndex on flash.display.Stage.


      The code attempting to run is this:

      quote:

      htmlControl.root.screenIndex = myVar


      How can I add a variable to this object?
        • 1. Re: Adding a custom variable to HTMLLoader
          Admiral_Brodnack Level 1
          Try:
          htmlControl.window.screenIndex = myVar;

          The root property references the display object container containing the HTMLLoader control (in this case the stage). In an HTML-based AIR app, you generally don't need to access such properties from the Flash side of the house, but since the HTMLoader is in fact a display object, such properties are accessible.

          • 2. Re: Adding a custom variable to HTMLLoader
            nvahalik Level 1
            I tried that... it doesn't seem to work. Perhaps it would be better to simply describe what I am trying to do.

            The application loads a web page and reloads it at specific intervals. The problem is that the page takes between 2-3 seconds to load completely. If the reload() method is called on the HTMLLoader object, the page will flash white for just a moment while it loads, and then display. To avoid this, I'd like to create another HTMLLoader behind the current object, load the page, then when the 'complete' event fires, swap the two HTMLLoader objects and destroy the old one. This would (hopefully) remove the flickering that has been experienced.