hackedteam/rcs-console

View on GitHub
src/it/ht/rcs/console/main/Section.mxml

Summary

Maintainability
Test Coverage
<?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
         xmlns:s="library://ns.adobe.com/flex/spark"
         xmlns:mx="library://ns.adobe.com/flex/mx"
         width="100%" height="100%" creationComplete="init()">

  <!-- Parent class for Section components -->
  
  <fx:Script>
    <![CDATA[
      import mx.containers.ViewStack;
      
      [Bindable]
      public var subSections:ViewStack;
      
//      [Bindable]
//      public var isDirty:Boolean = false;
      
      public function getDirtyState():Boolean { return false; }
      
      private function init():void
      {
        subSections = findSubSections();
      }
      
      /* if a section has subsections, it must expose a ViewStack with id == 'subSections' as its first element */
      
      private function findSubSections():ViewStack
      {
        try {
          var subSections:Object = this.getElementAt(0); // can throw Error. Unlikely (why empty section?)
          return (subSections is ViewStack && subSections.id == 'subSections') ? subSections as ViewStack : null;
        } catch (e:Error) {
        }
        return null;
      }
    ]]>
  </fx:Script>
  
</s:Group>