Subversion Repositories HomeAutomation

Rev

Rev 73 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

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