3 Replies Latest reply on Mar 15, 2012 1:17 AM by Innovatology

    Experienced developer, new to Flex, Architecture question

    VRHans Level 1

      Flash Builder 4.5, developing on Windows 7 64-bit, deploying on same


      I need to create a Desktop (will run on a kiosk) flex application that will consist of several 'layers' (I mean that in the logical organizational sense.)


      For this example, let's assume there will be 4 'layers.'


      Layer 1: Background covering the entire desktop

      Layer 2: Multiple components such as an HTML page in the middle near the top of the screen, and a custom component near the bottom of the screen

      Layer 3: Some flex components (a combo box for example, and maybe some sort of dialog)

      Layer 4: Some components (acting as 'widgets') that are meant to be always on top of everything (such as a button for launching help)


      This approach, which is necessary for product reasons, clearly indicates that Z-ordering/Layering of windows is going to be critical.


      In other development environments I would create a logical construct that represented a 'layer' in the application and that class would keep track of a set of components and manage their z-order.


      In Flash/Flex though I would *think* (and here's where my total noobery will shine through) that windows can have multiple components, and that windows can be transparent (only displaying components), therefore I could create a non-transparent window for layer 1, and transparent windows as containers for layers 2-4.  With each layer represented by a window, I would establish a parent-child relationship between layers to keep the window z-order locked (individual components in the same layer/window would have to be managed but I'm not worried about that.)


      Is this totally bass-ackwards?


      Is the idea of using windows as layers cosmically stupid?





        • 1. Re: Experienced developer, new to Flex, Architecture question
          Innovatology Level 3

          While the terminology you are using is not quite the same as Flash uses, in essence you are correct. In Flash it's called the Display Stack, and each of your "windows" is a DisplayObject which is placed on the Stage. Some DisplayObject descendants can contain other DisplayObjects in a parent-child relationship. They can be (semi-) transparent or irregularly shaped if you like.


          However, there is a bit of an obstacle. To use anything more than trivial HTML, you'll have to use StageWebView (for a desktop/AIR app) or an IFRAME (for an swf running in the browser). Neither of those are part of the Display Stack. A StageWebView is behind all other objects (and shows through transparent areas), while an IFRAME is generally in front of them. Whether that is a usable situation depends on your use-case and design requirements. It may take some tinkering and experimentation.

          • 2. Re: Experienced developer, new to Flex, Architecture question
            VRHans Level 1

            Thanks for that.


            My flex application is derived from WindowedApplication, does that mean that WindowedApplication is (behind the scenes) the first object on the "stage" or does that mean that the WindowedApplication class operates as the "stage"?


            Can I parent-child windows starting with my main application window?  I've tried that today and for some reason flash throws up if I add two windows as child elements of my WindowedApplication main window (I get an ::addChild() index out of bounds exception and only the first child window shows up on top of the WindowedApplication window.)  WindowedApplication class always errors when I call ::addChild on it with a message saying that you're not allowed to call addChild on this class (odd given that the documentation seems to say that you can...)


            I'm sure there are all kinds of caveats, so I'm just wondering if anyone reading this has had to slay this beast before.


            Thanks again,



            • 3. Re: Experienced developer, new to Flex, Architecture question
              Innovatology Level 3

              Oops, I messed up. StageWebView is in front of everyting else too. I was mixing it up with StageVideo.


              The Stage is a built-in object in Flash. Every .swf file has one. There may be some other housekeeping things too, but your WindowedApplication instance is the root item on the Stage.


              To add Flex controls, use AddElement instead of AddChild.


              You probably could just use Application instead of WindowedApplication if all you need is one (OS) window with multiple layers.