Subversion Repositories HomeAutomation

Rev

Rev 73 | Blame | Compare with Previous | Last modification | View Log | SVN | RSS feed

  1. import mx.utils.Delegate;
  2.  
  3. class ConfigObj {
  4.    
  5.     //var title:String;
  6.     //var description:String;
  7.     var contentsArr:Array = new Array();
  8.     var timeDate:TimeDateObj;
  9.     var comm:CommunicationObj;
  10.     var confDataXML:XML;
  11.     var mainMovieClip:MovieClip;
  12.     //länka till en menuitem och eller en xmlitem
  13.    
  14.     function ConfigObj (mainMovieClip:MovieClip) {
  15.         confDataXML.load("Flinsh_conf.xml");
  16.         confDataXML.ignoreWhite = true;
  17.         this.mainMovieClip = mainMovieClip;
  18.         //var dummyFnt:TextFormat = new TextFormat();
  19.         //dummyFnt.font = "MenuText";
  20.         confDataXML.onLoad = Delegate.create(this, onLoad);
  21.         //confDataXML.onLoad = onLoad();
  22.         //trace("ba");
  23.  
  24.        
  25.        
  26.     }       //end constructor
  27.    
  28.    
  29.     private function onLoad(success:Boolean) {
  30.         trace(confDataXML);
  31.             if (success) {
  32.                 var menuCnt:Number = 0;
  33.                 for (var aNode:XMLNode = confDataXML.firstChild; aNode != null; aNode=aNode.nextSibling) {
  34.                     //trace(aNode.nodeName);
  35.                     if (aNode.nodeName == "option") {
  36.                         switch (aNode.attributes.name) {
  37.                             case "backcolor":
  38.                             setBG(parseInt(aNode.attributes.value));
  39.                             break;
  40.                             case "backgroundimage":
  41.                                 if (aNode.attributes.value.length > 0) {
  42. //                                  bg_image.loadMovie(aNode.attributes.value);
  43.                                 }
  44.                             break;
  45.                             case "host":
  46.                                 if (aNode.attributes.value.length > 0) {
  47.                                     comm = new CommunicationObj(aNode.attributes.value);
  48.                                    
  49.                                     //gör om, parsa klart config innan commobj skapas, port kommer också
  50.                                 }
  51.                             break;
  52.                         }
  53.                     }
  54.                     if (aNode.nodeName == "item") {
  55.                         if (aNode.attributes.name == "type" && aNode.attributes.value == "menu") {
  56.                             //menushortname finns hos menyobjektet, skapa funktion som returnerar namn,
  57.                             //flinsh.fla får loopa igenom alla menyer och fråga om vems datan är
  58.                            
  59.                             //skicka med hela aNode som parameter till menuobj
  60.                             var menuConfig:XMLNode = aNode;
  61.                             contentsArr[menuCnt] = new MenuObj(mainMovieClip, menuConfig);
  62.            
  63.                             //contentsArr[menuCnt] = new MenuObj(mainMovieClip, confArr);
  64.                             contentsArr[menuCnt].showHide(true);
  65.  
  66.                             //testDataXML.load("testdata.xml");
  67.  
  68.                             menuCnt++;
  69.                         }
  70.                         if (aNode.attributes.name == "type" && aNode.attributes.value == "label") {
  71.                             //skicka med hela aNode som parameter till menuobj
  72.                             var labelConfig:XMLNode = aNode;
  73. //                          contentsArr[menuCnt] = new LabelObj(mainMovieClip, labelConfig);
  74.            
  75. //                          contentsArr[menuCnt].showHide(true);
  76. //                          menuCnt++;
  77.                         }
  78.                         if (aNode.attributes.name == "type" && aNode.attributes.value == "timedate") {
  79.                             //skicka med hela aNode som parameter till timedate
  80.                             var timeDateConfig:XMLNode = aNode;
  81.                             timeDate = new TimeDateObj(mainMovieClip, timeDateConfig);
  82.                         }
  83.                     }
  84.                 }
  85.                 if (comm != undefined) {
  86.                     comm.setDataReceiver(contentsArr);
  87.                 }
  88.             }
  89.            
  90.             //om inte succes ska log skrivas till fil?
  91.         };
  92.    
  93.     function setBG (col) {
  94.         var rp = -System.capabilities.screenResolutionX;
  95.         with (_level0) {
  96.             clear();
  97.             if (col != undefined) {
  98.                 beginFill(col);
  99.                 moveTo(rp, rp);
  100.                 //let us add 2 px each as flash eats them
  101.                 //in the Stage Object from the actual flash dimension
  102.                 lineTo(Stage.width*2, rp*2);
  103.                 lineTo(Stage.width*2, Stage.height*2);
  104.                 lineTo(rp*2, Stage.height*2);
  105.                 endFill();
  106.             }
  107.         }
  108.         mainMovieClip.__bg__ = col;
  109.     };     
  110.        
  111. /*
  112. var testDataXML:XML = new XML();
  113.  
  114. testDataXML.ignoreWhite = true;
  115. testDataXML.onLoad = function(success:Boolean) {
  116.     if (success) {
  117.         if (testDataXML.firstChild.nodeName == "contentdata") {
  118.             //Data should be sent to menu
  119.             //right now Flinsh have only one menu, send data to it
  120.             menuArr[0].setNewData(testDataXML.firstChild);
  121.         }
  122.         //trace("bingo");
  123.         //trace("loaded: "+testDataXML.loaded);
  124.         //trace("status: "+testDataXML.status);
  125.     }
  126.    
  127.     //om inte succes ska log skrivas till fil?
  128. };
  129. */
  130.        
  131.        
  132. }