10 Replies Latest reply on Mar 4, 2010 7:39 AM by rexdtripod

    Custom components laid out in mxml sometimes don't paint right

    rexdtripod Level 1

      When I lay out custom components on the screen in MXML, sometimes on starting the app they wind up all scrunched up in a tiny square in the upper left hand corner of the window.  They don't get sized and positioned.  It's not all the time.  Intermittent.

       

      What's the cause?

       

      I see many people use the createChildern() and updateDisplayList() methods and do layout in ActionScript.  Is this why they do this?  Is there some inherent problem in laying components out in mxml?

        • 1. Re: Custom components laid out in mxml sometimes don't paint right
          cheftimo Level 2

          Sounds like you are using layout="absolute", in which case you must specify x and y coordinates for the components you add.

           

          HTH,

           

          Carlos

          • 2. Re: Custom components laid out in mxml sometimes don't paint right
            rexdtripod Level 1

            Yes.  They are specified.  Why are they sometimes not honored?   Again, intermittently.

            • 3. Re: Custom components laid out in mxml sometimes don't paint right
              Gregory Lafrance Level 6

              If your components are all getting placed in the top-left of a container using absolute layout, often it is because the container that actually contains the components does not have a width/height set properly. Sometimes you set them to 100% and they will then occupy all of its parent container, or you will set a specific width / height.

               

              If this post answers your question or helps, please mark it as such.


              Greg Lafrance - Flex 2 and 3 ACE certified

              www.ChikaraDev.com

              Flex / AIR Development, Training, and Support Services

              1 person found this helpful
              • 4. Re: Custom components laid out in mxml sometimes don't paint right
                rexdtripod Level 1

                Hmmm...  The container that contains the components, in this case, is the application.

                 

                I would think that not setting the size on the conatiner of the components would produce the result 100% of the time.  This happens so infrequently.  It's really wierd.  If I run the app 100 times I don't get it.

                 

                We recently had an event with the app where about 600 people logged on and used it.  Two out of the 600 reported it.  One sent a screen shot to one of our support people.  I'm trying to track it down.

                 

                I've had it happen to me in the past but it's very infrequent.  Still, people freak when they see it.

                 

                I'm wondering if it's related to available processing power or memory at the moment it happens.  I'm also wondering if I'm just making some fundamental mistake in handling the UI.

                 

                Again, should laying components out in MXML be avoided?  Is there additional overhead?  Should I be setting app height and width to 100%?  Should I be placing all components inside a Canvas in the app and set that to width and height 100%?  Should I be forcing a manual UI update with a call to validateNow() when the app is finished initializing?  Not sure which tree to bark up just yet.

                • 5. Re: Custom components laid out in mxml sometimes don't paint right
                  jsd99 Level 3

                  Set the app width and height to 100%.  The overhead in laying out a UI comes from using relative sizes/positions (width specified as percentage, use of top/bottom).  If you want maximum speed, use absolute layout everywhere (canvases with components explicitly positioned with x, y, width & height).

                   

                  That said, unless you are going absolutely crazy (thousands of UI elements relatively positioned) then you probably won't notice any speed issues except maybe on super old computers.

                  1 person found this helpful
                  • 6. Re: Custom components laid out in mxml sometimes don't paint right
                    rexdtripod Level 1

                    Not using absolute layout.  It's a fluid layout so using canvases with percentages.

                     

                    Still not getting to the heart of the matter though which is the intermittent nature of the problem.  With my current layout, the success rate of the layout painting correctly is well over 99%.

                     

                    Is setting the app width and height to 100% going to fix that other 1% or less.  What's the actual cause of the problem?  I feel like I'm just throwing things at the wall hoping something will stick.

                    • 7. Re: Custom components laid out in mxml sometimes don't paint right
                      Gregory Lafrance Level 6

                      If you are using Canvas then you are using absolute layout because that's all Canvas supports., unless you are using containers like VBox in the Canvas.

                       

                      Maybe boil your code to minimal code that still shows issue, and post that.

                       

                      If this post answers your question or helps, please mark it as such.


                      Greg Lafrance - Flex 2 and 3 ACE certified

                      www.ChikaraDev.com

                      Flex / AIR Development, Training, and Support Services

                      • 8. Re: Custom components laid out in mxml sometimes don't paint right
                        rexdtripod Level 1

                        Right.  Sorry.  Yes, absolute layout, canvas containers, and percentages within canvases.

                         

                        Can't do the boil down thing.  I hardly see the issue with the mountains of code I have.  Like I said.  Of over 600 logged in users only two reported the issue via my tech chat component. If you just throw 5 panels in an app it would be a boiled down version of my app.

                         

                        I think it might be some perfect storm of a large number of components, taxed cpu, low memory, and poor bandwidth that hits all at once.

                         

                        Plus the app streams live h.264 video from FMS.

                         

                        Duplicating it will probably be a matter of throttling back bandwidth and opening lots of other apps while trying to load the app.

                         

                        I'm wondering if there is some way to detect the issue on the fly and force a repaint.  Pretty tough issue.

                        • 9. Re: Custom components laid out in mxml sometimes don't paint right
                          Christopher McArthur

                          Our application had this exact same problem. Very very rarely a small percentage of our users would have a screen show up exactly as you said. And we were using the same type of layout that you had.

                           

                          The problem ended up being an unhandled exception that was being thrown in initialization of the view somewhere, which caused the parents view width/height to not be set properly, and then everything got squished together in the upper left hand corner.

                           

                          Unfortunately, finding this exception was very difficult and it wasnt until we were lucky enough to catch it in the debugger that we were able to fix it. It turned out to be a timing issue, and misuse of referring to a child component in a creationComplete.

                          • 10. Re: Custom components laid out in mxml sometimes don't paint right
                            rexdtripod Level 1

                            Thanks for your response.  Figured it had to be something like that - timing, or resource depletion - something that is scarce and tough to reproduce.

                             

                            The chances of me catching that exception are pretty slim.  If you can recall anything specific that might help me zero in on a culprit, let me know.

                             

                            Again, thanks for sharing that.

                             

                            Robert