4 Replies Latest reply on Jan 3, 2007 1:56 PM by danFromBAH

    Tree generates 1502 error

    danFromBAH Level 1
      I am using an mx: Tree tag to display a tree that has 1442 child nodes (and the child nodes have nested children). When I try to expand the nodes nearer the bottom of the tree, there is some delay and then a 1502 error is generated, as shown in the stack trace below.

      I am sure I am not managing the lifecycle of the tree properly, but I would appreciate any help with this issue.

      Error: Error #1502: A script has executed for longer than the default timeout period of 15 seconds.
      at mx.controls.treeClasses::HierarchicalViewCursor/seek()
      at mx.controls.listClasses::ListBase/mx.controls.listClasses:ListBase::scrollVertically()
      at mx.controls::List/mx.controls:List::scrollHandler()
      at mx.controls::Tree/mx.controls:Tree::scrollHandler()
      at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
      at flash.events::EventDispatcher/dispatchEvent()
      at mx.controls.scrollClasses::ScrollBar/ http://www.adobe.com/2006/flex/mx/internal::dispatchScrollEvent()
      at mx.controls.scrollClasses::ScrollThumb/::mouseMoveHandler()

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"
      layout="absolute" creationComplete="CursorManager.setBusyCursor();getGlobalTypesRPC.send();">

      <mx:HTTPService id="getGlobalTypesRPC"
      resultFormat="e4x" showBusyCursor="true" method="post"
      <mx:XMLListCollection id="globalTypes"
      source="{getGlobalTypesRPC.lastResult.type}" />

      <mx:HTTPService id="getChildrenTypesRPC"
      resultFormat="e4x" showBusyCursor="true" method="post"
      <mx:XMLListCollection id="childrenTypes"
      source="{getChildrenTypesRPC.lastResult.type}" />

      import mx.events.*;
      import mx.controls.*;
      import mx.rpc.events.ResultEvent;
      import mx.controls.treeClasses.*;
      import mx.collections.XMLListCollection;
      import mx.managers.CursorManager;

      public var domainList: Array = [
      {label:"Emergency Management", data:" http://niem.gov/niem/domains/emergencyManagement/1.0"},
      {label:"Immigration", data:" http://niem.gov/niem/domains/immigration/1.0"},
      {label:"Infrastructure Protection", data:" http://niem.gov/niem/domains/infrastructureProtection/1.0"},
      {label:"Intelligence", data:" http://niem.gov/niem/domains/intelligence/1.0"},
      {label:"International Trade", data:" http://niem.gov/niem/domains/internationalTrade/1.0"},
      {label:"Justice", data:" http://niem.gov/niem/domains/justice/1.0"},
      {label:"Person Screening", data:" http://niem.gov/niem/domains/screening/1.0"} ];

      private var selectedDomain:Object;

      private var selectedType:Object;

      private var selectedNode:Object;

      private function showDesc(event:Event):void{
      var selectedNode:Object = event.target.selectedItem;
      type.text = selectedNode.@type;
      desc.text = selectedNode.@annotation;

      private function itemOpen(event:TreeEvent):void {
      selectedNode = event.item;
      selectedType = selectedNode;
      var descriptor:ITreeDataDescriptor = tree.dataDescriptor;

      if (!descriptor.hasChildren(selectedNode)) {

      private function getGlobalTypesRPCHandler(event:ResultEvent):void {
      tree.dataProvider = globalTypes;
      tree.selectedIndex = 0;
      type.text = tree.dataProvider[0].@type;
      desc.text = tree.dataProvider[0].@annotation;

      private function getChildrenTypesRPCHandler(event:ResultEvent):void {
      for (var i:int = 0; i < childrenTypes.length; i++) {
      var newNode:XML = <type/>;
      var child:Object = childrenTypes.getItemAt(i);
      newNode.@name = child.@name;
      newNode.@type = child.@type;
      newNode.@annotation = child.@annotation;
      newNode.@isBranch = child.@isBranch;
      newNode.@namespaceURI = child.@namespaceURI;
      newNode.@isAttribute = child.@isAttribute;
      newNode.@isAbstract = child.@isAbstract;
      newNode.@isAttributeGroup = child.@isAttributeGroup;
      newNode.@isElement = child.@isElement;
      newNode.@isModelGroup = child.@isModelGroup;
      newNode.@isSimpleType = child.@isSimpleType;

      private var complexTypeIcon:Class;
      private var attributeTypeIcon:Class;
      private var elementTypeIcon:Class;
      private var simpleTypeIcon:Class;

      private function treeIconFunc(item:Object):Class {
      var docType:Class;

      if(item.@isComplexType == "true") {
      docType = complexTypeIcon;
      } else if(item.@isAttribute == "true") {
      docType = attributeTypeIcon;
      } else if(item.@isElement == "true") {
      docType = elementTypeIcon;
      } else if(item.@isSimpleType == "true") {
      docType = simpleTypeIcon;

      return docType;

      private function treeLabelFunc(item:Object) : String
      var node:XML = XML(item);
      if( node.@isAbstract == "true" )
      return node.@name + "(Abstract)";
      return node.@name;

      private function domainsClose(event:Event):void {

      <mx:Panel layout="absolute" left="0" right="0" bottom="0" top="0">

      <mx:ComboBox id="domains" left="10" right="10" top="10" rowCount="7"

      <mx:Label x="10" y="40" text="Type" />
      <mx:TextInput y="38" right="10" left="81" editable="false"
      id="type" />
      <mx:TextArea y="66" height="50" right="10" left="81" id="desc"
      editable="false" horizontalScrollPolicy="auto" />
      <mx:Label x="7" y="67" text="Description" />

      <mx:Tree id="tree" top="124" bottom="10" right="10" left="10"
      itemRenderer="NIEMTreeItemRenderer" iconFunction="treeIconFunc"


        • 1. Re: Tree generates 1502 error
          ntsiii Level 3
          No, with this large a tree, you are just hitting the default Flash Player timeout.

          The default is 15 seconds, but that can be set as high a 60 seconds using the property on the Application tag: scriptTimeLimit. See the docs for more info:

          • 2. Re: Tree generates 1502 error
            danFromBAH Level 1

            The documentation states that the default value for 'scriptTimeLimit' is 60 seconds. Anyway, I added that attribute to my mx:Application tag and I am still having the same issue. The data used to populate the tree is cached on the server side and little latency in the transfer of this data from the server to the client (fast server + large network bandwidth).

            Here is what I am seeing. Visualize an mx:Tree with 1442 nodes. The nodes near the top of the three can be expanded and viewed without a problem.

            If I try to expand the last node, it expands, but I can't see it children. I have to move the scroller up until the last node is hidden from view and then scroll down to see its children.

            In some instances, the node I try to expand disappears from view completely, until I move the scroll bar up and down a few times, and then it reappears

            In some instances, a node near the bottom of the tree expands successfully, but it's children are displayed as if they were siblings of the top most nodes of the tree. After moving the scroll bar up and down, the children are re-rendered as sub-nodes of the the node I expanded.

            In some instances, I get a 1509 error when I try expand a node

            Having said all that, I notice I have none of these issues when the tree is relatively small (<500 nodes).

            • 3. Re: Tree generates 1502 error
              ntsiii Level 3
              Ok, the error message fooled me.

              It might be time to contact Adobe support. I have worked with 30,000 + node trees in 1.5, but never in 2.0.

              How are you setting the tree dataProvider? Binding, or in a result handler? whichever, try the other.

              • 4. Re: Tree generates 1502 error
                danFromBAH Level 1
                I have tried both approaches (result handler and binding). I believe my problem is associated with the way I am adding new nodes to the tree. If I create the same tree with all children prepopulated, all is well. On the other hand, if I populated the top level nodes only and then populate the children of those nodes on 'itemOpen' event, I see the problem.

                Is there a way to force the tree to repaint itself?