[ Flash AS ] Ticker refresh geeft problemen

Pagina: 1
Acties:

  • Intheweb
  • Registratie: April 2005
  • Laatst online: 10:31
Sinds een aantal dagen ben ik druk bezig met het ontwikkelen van een applicatie die straks in de foyer van een theater moet gaan draaien voor twee dagen.

Er word een video getoond die in een loop staat, word een live beeld getoond wat uit een regie set komt (via de nieuwe Flash Encoder) en onderin komt een tickertape. En dat is nu even het punt wat kopzorgen geeft.

Op http://dichterbij.intheweb.nl/files/foyer/ is de versie tot nu toe te zien.
De ticker onder in beeld herlaad zich zelf automatisch na het laten zien van de laatste uit de serie.
De ticker word ingeladen uit een XML bestand.

Probleem is dat hij na 3 keer te hebben rondgedraaid de animatie niet meer sync loopt met de rest.

Hieronder mijn script dat ik gebruik.

Het probleem is dus vooral dat de refresh van de XML niet soepel verloopt, hoe kan ik dit oplossen? Heb al een aantal dingen geprobeerd en de plek van de refresh te wijzigen, maar helaas.
Tevens hoor ik graag tips om dit script te optimaliseren :)

code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/////////////////////////////////////////////////////////
// Begin of the ticker

function loadXML(loaded) {
    if (loaded) {
        xmlNode = this.firstChild;
        // Make the varibales
        names = [];
        messages = [];
        pictures = [];
        dates = [];
        total = xmlNode.childNodes.length;

        for (i=0; i<total; i++) {
            names[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
            messages[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
            pictures[i] = xmlNode.childNodes[i].childNodes[2].firstChild.nodeValue;
            dates[i] = xmlNode.childNodes[i].childNodes[3].firstChild.nodeValue;
        }
        delete xmlData;
        first_item();
    } else {
        content = "file not loaded!";
    }
}

// Start the XML
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("http://dichterbij.intheweb.nl/rss/webcamdoos/"+random(999));
//

// Display the first function
function first_item() {
    delay = 5000;
    p = 0;
    display(p);
    p++;
}

function timer(pos) {
    myInterval = setInterval(ticker, delay);
    function ticker() {
        clearInterval(myInterval);
        if (p == total) {
            p = 0;
        }
        tickeravatar_mc.gotoAndPlay(11);
        fadeout();
        
    }
}

function display(pos) {
    over = new TextFormat();
    over.underline = true;
    //
    out = new TextFormat();
    out.underline = false;
    //
    uitleg_mc.tickerTxt._alpha = 100;
    _root.tickeravatar_mc.tickerTxt.text = messages[pos];
    
    // Put the name in the name MC
    _root.tickeravatar_mc.tickername_mc.tickerName.text = names[pos];
    
    // Put the avatar in the avatar MC
    if(pictures[pos] == "0") {
        _root.tickeravatar_mc.tickerpic_mc.loadMovie("http://dichterbij.intheweb.nl/images/icons/no_avatar.gif");
    } else {
        _root.tickeravatar_mc.tickerpic_mc.loadMovie(pictures[pos]);
    }
    
    // Play the animation for the avatar and anem
    tickeravatar_mc.gotoAndPlay(2);
    
    // Get the position counter 1 up
    var realPos:Number = pos;
    realPos++;
    // Check if the last message has been reach. If so, then reload the XML feed
    if(realPos == total) {
        // Start the XML
        xmlData = new XML();
        xmlData.ignoreWhite = true;
        xmlData.onLoad = loadXML;
        xmlData.load("http://dichterbij.intheweb.nl/rss/webcamdoos/"+random(999));
    } else {
        
    }
    
    // execute timer
    timer();
}

function fadeout() {
    this.onEnterFrame = function() {
        display(p);
        p++;
        delete this.onEnterFrame;
    };
}

// End of ticker
/////////////////////////////////////////////////////////

Doe maar een onsje meer...


  • Intheweb
  • Registratie: April 2005
  • Laatst online: 10:31
Een voorzichtige kick...

Iemand? :)

Doe maar een onsje meer...


  • McVirusS
  • Registratie: Januari 2000
  • Laatst online: 23-10 00:49
Ben je er inmiddels al uit?

  • Intheweb
  • Registratie: April 2005
  • Laatst online: 10:31
Ja :D

Probleem wat dat de cache vol zat met de oude berichten en tegelijkertijd werden dezelfde berichten overschreven door de nieuwe... dit gaf veel problemen.

Dus bij het inladen van de nieuwe informatie werd gelijk de oude nu gedumpt.
Hierbij de code voor de geintresseerden:

code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/////////////////////////////////////////////////////////
// Begin of the ticker

fscommand('fullscreen', TRUE);

function loadXML(loaded) {
    if (loaded) {
        xmlNode = this.firstChild;
        // Make the varibales
        names = [];
        messages = [];
        pictures = [];
        dates = [];
        total = xmlNode.childNodes.length;

        for (i=0; i<total; i++) {
            names[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
            messages[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
            pictures[i] = xmlNode.childNodes[i].childNodes[2].firstChild.nodeValue;
            dates[i] = xmlNode.childNodes[i].childNodes[3].firstChild.nodeValue;
        }
        delete xmlData;
        first_item();
    } else {
        content = "file not loaded!";
    }
}

function loading() {
// Start the XML

delete names;
delete messages;
delete pictures;
delete dates;
delete total;
delete pos;

xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("http://dichterbij.intheweb.nl/rss/webcamdoos/"+random(999));
//
}

// Display the first function
function first_item() {
    delay = 5000;
    p = 0;
    display(p);
    p++;
}

function timer(statusTicker) {
    // Set the timer to swith to a new message
    myInterval = setInterval(ticker, delay);
    function ticker() {
        clearInterval(myInterval);
        if (p == total) {
            p = 0;
        }
    
        tickeravatar_mc.gotoAndPlay(11);
        fadeout();
    }
}

function display(pos) {
    over = new TextFormat();
    over.underline = true;
    //
    out = new TextFormat();
    out.underline = false;
    //
    _root.tickeravatar_mc.ticker_mc.tickerTxt._alpha = 100;
    _root.tickeravatar_mc.ticker_mc.tickerTxt.htmlText = messages[pos];
    
    // Put the name in the name MC
    _root.tickeravatar_mc.tickername_mc.tickerName.text = names[pos];
    
    // Put the avatar in the avatar MC
    if(pictures[pos] == "0") {
        _root.tickeravatar_mc.tickerpic_mc.loadMovie("http://dichterbij.intheweb.nl/images/icons/no_avatar.gif");
    } else {
        _root.tickeravatar_mc.tickerpic_mc.loadMovie(pictures[pos]);
    }
    
    // Play the animation for the avatar and name
    tickeravatar_mc.gotoAndPlay(2);
    //trace(pos);
    
    // Get the position counter 1 up
    var realPos:Number = pos;
    realPos++;
    // Check if the last message has been reach. If so, then reload the XML feed
    if(realPos == total) {
        loading();
    } else {
        timer();
    }
}

function fadeout() {
    this.onEnterFrame = function() {
        if (_root.tickeravatar_mc.ticker_mc.tickerTxt._alpha>=0) {
            _root.tickeravatar_mc.ticker_mc.tickerTxt._alpha -= 5;
        } else {
            display(p);
            p++;
            delete this.onEnterFrame;
        }       
    };
}

// Start the ticker
loading();

// End of ticker
/////////////////////////////////////////////////////////

Doe maar een onsje meer...