8 Replies Latest reply on Oct 25, 2006 6:59 AM by keyboardlacky

    Limit to complexity

    keyboardlacky
      I'm trying to implement an interface in Flex with probably over 100 textInput fields wrapped inside of custom input view components (some with custom events) along with other label and text components. Most of these components bind to an XML object.

      I'm starting to see inexplicable hanging and timeout errors when running the application. I can make this happen just by adding "one more" component to a list of identical components.

      Is there a practical limit to doing this in Flex? Am I using the wrong platform for developing a complex input application such as this? or am I just most likely implementing thing poorly?

      Thanks in advance,
      David
        • 1. Re: Limit to complexity
          keyboardlacky Level 1
          The message I'm getting when adding the last additional line that breaks the camel's back is:

          quote:


          Error: Error #1502: A script has executed for longer than the default timeout period of 15 seconds.
          at mx.binding::Binding/mx.binding:Binding::wrapFunctionCall()
          at mx.binding::Binding/execute()
          at mx.binding::Binding/watcherFired()
          at mx.binding::Watcher/notifyListeners()
          at mx.binding::XMLWatcher/xmlNotification()
          at MethodInfo-4901()
          at MethodInfo-2329()
          at Function/ http://adobe.com/AS3/2006/builtin::apply()
          at mx.binding::Binding/mx.binding:Binding::wrapFunctionCall()
          at mx.binding::Binding/::innerExecute()
          at Function/ http://adobe.com/AS3/2006/builtin::apply()
          at mx.binding::Binding/mx.binding:Binding::wrapFunctionCall()
          at mx.binding::Binding/execute()
          at mx.binding::Binding/watcherFired()
          at mx.binding::Watcher/notifyListeners()
          at mx.binding::XMLWatcher/xmlNotification()
          at MethodInfo-4901()
          at MethodInfo-2323()
          at Function/ http://adobe.com/AS3/2006/builtin::apply()
          at mx.binding::Binding/mx.binding:Binding::wrapFunctionCall()
          at mx.binding::Binding/::innerExecute()
          at Function/ http://adobe.com/AS3/2006/builtin::apply()
          at mx.binding::Binding/mx.binding:Binding::wrapFunctionCall()
          at mx.binding::Binding/execute()
          at mx.binding::Binding/watcherFired()
          at mx.binding::Watcher/notifyListeners()
          at mx.binding::XMLWatcher/xmlNotification()
          at MethodInfo-4901()
          at MethodInfo-1835()
          at Function/ http://adobe.com/AS3/2006/builtin::apply()
          at mx.binding::Binding/mx.binding:Binding::wrapFunctionCall()
          at mx.binding::Binding/::innerExecute()
          at Function/ http://adobe.com/AS3/2006/builtin::apply()
          at mx.binding::Binding/mx.binding:Binding::wrapFunctionCall()
          at mx.binding::Binding/execute()
          at mx.binding::Binding/watcherFired()
          at mx.binding::Watcher/notifyListeners()
          at mx.binding::XMLWatcher/xmlNotification()
          at MethodInfo-4901()
          at MethodInfo-2331()
          at Function/ http://adobe.com/AS3/2006/builtin::apply()
          at mx.binding::Binding/mx.binding:Binding::wrapFunctionCall()
          at mx.binding::Binding/::innerExecute()
          at Function/ http://adobe.com/AS3/2006/builtin::apply()
          at mx.binding::Binding/mx.binding:Binding::wrapFunctionCall()
          at mx.binding::Binding/execute()
          at mx.binding::Binding/watcherFired()
          at mx.binding::Watcher/notifyListeners()
          at mx.binding::XMLWatcher/xmlNotification()
          at MethodInfo-4901()
          at MethodInfo-2321()
          at Function/ http://adobe.com/AS3/2006/builtin::apply()
          at mx.binding::Binding/mx.binding:Binding::wrapFunctionCall()
          at mx.binding::Binding/::innerExecute()
          at Function/ http://adobe.com/AS3/2006/builtin::apply()
          at mx.binding::Binding/mx.binding:Binding::wrapFunctionCall()
          at mx.binding::Binding/execute()
          at mx.binding::Binding/watcherFired()
          at mx.binding::Watcher/notifyListeners()
          at mx.binding::PropertyWatcher/eventHandler()
          at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
          at flash.events::EventDispatcher/dispatchEvent()
          at view::FullHUDForm2/set xmlHUD()
          at MethodInfo-505()


          • 2. Re: Limit to complexity
            leotemp Level 1
            looks like between waiting for xml, events and all the other things going on a critical timeout is occuring. If all that complexity is needed and you cant streamline it anymore either in your backend or in the flex app, then perhaps consider breaking the UI into seperate smaller apps.
            • 3. Re: Limit to complexity
              keyboardlacky Level 1
              Thanks for the reply, leotemp. I've not tried that yet. I'm also considering storing the XML data in a custom class instance and pulling from the object instead of the XML file itself. It seams like this might reduce complexity during runtime. I just started with the easiest (accessing and modifying the xml directly) and am moving on from there. Are there downsides to splitting into separate applications? I need to calculate numbers based on fields from scattered portions of the xml, so I need everything to talk to each other.

              Thanks again,
              David
              • 4. Re: Limit to complexity
                ntsiii Level 3
                You can set this timeout value as high as 60 seconds. The property is on the Application tag and is called scriptTimeout, I believe.

                Also, does this happen at startup? Does your app take a long time to load? what kinds of containers are you using? Are you taking advantage of deferred instantiation? Have you set creationPolicy="all"? (if so, un-do that, if not, never mind)

                If you add a control that is not bound, does it cause the timeout?

                How are you binding to the data? Directly to the lastResult object, or are you using a result handler to assing the data to a global variable?

                Tracy
                • 5. Re: Limit to complexity
                  keyboardlacky Level 1
                  Thanks for the troubleshooting help, Tracy. I've put the answers to your questions below. But, before I get to those, I must ask if the whole idea of using this many binding expressions directly to an XML object is a bad idea? Should I be transferring the data to a strongly typed custom class object first and then transferring back to XML to store/translate? Each of the binding expressions look like this (or simpler):

                  {myxml.section.(@id=='l').item.(@id=='703').value.(@type='primary')}

                  Here are the answers to your questions:
                  quote:

                  [You can set this timeout value as high as 60 seconds. The property is on the Application tag and is called scriptTimeout, I believe.
                  I have not changed the timeout value yet. I'm hoping to avoid that.



                  quote:

                  Also, does this happen at startup?
                  Yes.



                  quote:

                  Does your app take a long time to load?
                  Only when I add these couple of extra objects.



                  quote:

                  what kinds of containers are you using?
                  The custom view components are all HBox objects. Inside of these are TextInput objects and Labels. The TextInput uses a custom currency formatter to parse any input and re-format it to a currency value or replace it with it's previous value (if it isn't recognized as a currency).



                  quote:

                  Are you taking advantage of deferred instantiation? Have you set creationPolicy="all"? (if so, un-do that, if not, never mind)
                  I haven't changed the creationPolicy. Right now, i'm just testing the application with just one component that wraps all of these other custom components into a couple of VBox's and puts those into a TabNavigator.



                  quote:

                  If you add a control that is not bound, does it cause the timeout?
                  No, actually it doesn't. I hadn't thought to just put in static values before, but that doesn't cause it to time out. Also, I just tried replacing the components in question with what I thought were nearly identical components, and they do not cause this problem, even when bound to the same data. It looks like I need to drill into this component.



                  quote:

                  How are you binding to the data? Directly to the lastResult object, or are you using a result handler to assing the data to a global variable?
                  I'm using a result handler, see below...
                  quote:


                  <mx:Script>
                  <![CDATA[

                  import mx.rpc.events.ResultEvent;

                  [Bindable]
                  private var myxml:XML;

                  private function initApp():void
                  {
                  myService.send();
                  }

                  private function serviceResultHandler(event:ResultEvent):void
                  {
                  myxml= XML(event.result);
                  }

                  ]]>
                  </mx:Script>

                  <mx:HTTPService id="myService"
                  url="data/blank.xml"
                  resultFormat="e4x"
                  result="serviceResultHandler(event)"/>


                  • 6. Re: Limit to complexity
                    keyboardlacky Level 1


                    I'm an idiot... notice the last filter expression I used (arrgh):
                    {myxml.section.(@id=='l').item.(@id=='703').value.(@type='primary')}
                    only one equal sign!

                    So, even though I've discovered the problem with this error, I still wonder if it is appropriate for me to bind directly to an XML property like this for each field as opposed to transferring the data to strongly type custom objects?

                    Thanks,
                    David

                    • 7. Re: Limit to complexity
                      ntsiii Level 3
                      That single equal has kicked my butt more than once! But it feels really good to find that is the problem, doesn't it? Happily, the AS# compiler can catch it sometimes, but obviously not in an expression like that.

                      Binding directly to an e4x expession is just fine. But using strongly typed variables/properties will be easier to debug/maintain. I personally do not like binding to complex expressions because they are hard to debug. As you noticed!

                      Tracy

                      • 8. Re: Limit to complexity
                        keyboardlacky Level 1
                        Thanks again for the input Tracy. I probably will have to add the custom objects in the near future.

                        David