PVWEERT
%Europe/Berlin %882 %2005, 22:10
Ik heb de volgende code gebruikt in mijn swf:
// INIT
var loadUrl = "http://paulv.ovalon.com/go/medium/tv"; // KAN OOK DYNAMISCH IN BRON VAN HTML
xmlDoc = new XML();
xmlDoc.ignoreWhite = true;
xmlDoc.load (loadUrl);
xmlDoc.onLoad = function() {
checkTemplate(this);
}
// Variables
var templateStart = "xmlDoc.firstChild.firstChild.firstChild.nextSiblin g.nextSibling.nextSibling.firstChild";
var templateCount = ""; // .nextSibling add
var templateEnd = ".firstChild.childNodes";
var checked = "";
var viewtime = "";
// COUNTER
var clockSheet = "0"
var countTimer:Number = 1
var timeSheet = "0"
var timerClock = setInterval(timerSheet, 1000);
// CHECK TEMPLATE
function checkTemplate() {
var toCheck = _root.templateStart + _root.templateCount + _root.templateEnd
var viewTimeVar = "xmlDoc.firstChild.firstChild.firstChild.nextSiblin g.nextSibling.nextSibling.attributes.viewtime";
// trace(eval(viewTimeVar));
set("_root.checked", eval(toCheck));
set("_root.viewtime", eval(viewTimeVar));
// trace(_root.viewtime);
trace("_root.checked: " + _root.checked);
actCheck();
};
// DEVIDE BY TEMPLATE
function actCheck() {
if (_root.checked == undefined) {
set("_root.templateCount", "");
// trace("templateCount is emptied (value:" + _root.templateCount + ")");
restart();
} else if (_root.checked = "ARTICLE_IMAGE") {
_root.holder.loadMovie("ARTICLE_IMAGE.swf");
// loadARTICLE_IMAGE();
} else if (_root.checked = "IMAGE") {
_root.holder.loadMovie("IMAGE.swf");
// loadIMAGE();
} else if (_root.checked = "DOCUMENT") {
trace("no template for DOCUMENT set");
// _root.holder.loadMovie("DOCUMENT.swf");
addCount();
} else {
trace("error in actCheck");
};
};
// LOAD ARTICLE_IMAGE TEMPLATE AND PLAY -- CALLED BY TEMPLATE
function setARTICLE_IMAGE() {
var evalTitle = _root.templateStart + _root.templateCount + ".firstChild.nextSibling.firstChild.childNodes"
var evalSubtitle = _root.templateStart + _root.templateCount + ".firstChild.nextSibling.firstChild.nextSibling.chi ldNodes"
var evalIntro = _root.templateStart + _root.templateCount + ".firstChild.nextSibling.firstChild.nextSibling.nex tSibling.childNodes"
var evalText = _root.templateStart + _root.templateCount + ".firstChild.nextSibling.firstChild.nextSibling.nex tSibling.nextSibling.childNodes"
var evalImage = _root.templateStart + _root.templateCount + ".firstChild.nextSibling.firstChild.nextSibling.nex tSibling.nextSibling.nextSibling.firstChild.firstC hild.nextSibling.childNodes"
_root.holder.imageBox.loadMovie((eval(evalImage))) ;
_root.holder.titleBox.text = eval(evalTitle);
_root.holder.subtitleBox.text = eval(evalSubtitle);
_root.holder.introBox.text = eval(evalIntro);
_root.holder.textBox.text = eval(evalText);
set("_root.clockSheet", "1");
set("_root.countTimer", 1);
};
// LOAD IMAGE TEMPLATE AND PLAY
function setIMAGE() {
var evalImage = _root.templateStart + _root.templateCount + ".firstChild.nextSibling.firstChild.nextSibling.chi ldNodes"
_root.holder.imageBox.loadMovie((eval(evalImage))) ;
set("_root.clockSheet", "1");
set("_root.countTimer", 1);
};
// LOAD DOCUMENT TEMPLATE AND PLAY
function setDOCUMENT() {
// NO TEMPLATE SET
};
// timeSHEET
function timerSheet() {
if (_root.clockSheet == "1") {
if (_root.viewtime == _root.countTimer) {
clearInterval(timerClock);
trace("gelijk");
addCount();
} else {
trace("tellen");
set("_root.countTimer", _root.countTimer + 1);
};
};
};
// PREPARE RESTART
function addCount() {
set("_root.templateCount", _root.templateCount + ".nextSibling");
// trace(_root.templateCount);
restart();
};
// RESTART
function restart() {
_root.holder.unloadMovie();
checkTemplate();
};
// EIND PLAYER
stop();
In de in geladen swf's wordt setIMAGE() of setARTICLE_IMAGE() aangeroepen.
Echter gaat hij naar de tweede keer dat hij moet kijken wat voor template het is bij de functie actCheck gewoon door met het template ARTICLE_IMAGE en niet met IMAGE wat het in de .xml is. Wel laat hij IMAGE in als _root.checked. Er gaat dus iets fout bij de else if constructie in mijn ogen.
Maar wat?
// INIT
var loadUrl = "http://paulv.ovalon.com/go/medium/tv"; // KAN OOK DYNAMISCH IN BRON VAN HTML
xmlDoc = new XML();
xmlDoc.ignoreWhite = true;
xmlDoc.load (loadUrl);
xmlDoc.onLoad = function() {
checkTemplate(this);
}
// Variables
var templateStart = "xmlDoc.firstChild.firstChild.firstChild.nextSiblin g.nextSibling.nextSibling.firstChild";
var templateCount = ""; // .nextSibling add
var templateEnd = ".firstChild.childNodes";
var checked = "";
var viewtime = "";
// COUNTER
var clockSheet = "0"
var countTimer:Number = 1
var timeSheet = "0"
var timerClock = setInterval(timerSheet, 1000);
// CHECK TEMPLATE
function checkTemplate() {
var toCheck = _root.templateStart + _root.templateCount + _root.templateEnd
var viewTimeVar = "xmlDoc.firstChild.firstChild.firstChild.nextSiblin g.nextSibling.nextSibling.attributes.viewtime";
// trace(eval(viewTimeVar));
set("_root.checked", eval(toCheck));
set("_root.viewtime", eval(viewTimeVar));
// trace(_root.viewtime);
trace("_root.checked: " + _root.checked);
actCheck();
};
// DEVIDE BY TEMPLATE
function actCheck() {
if (_root.checked == undefined) {
set("_root.templateCount", "");
// trace("templateCount is emptied (value:" + _root.templateCount + ")");
restart();
} else if (_root.checked = "ARTICLE_IMAGE") {
_root.holder.loadMovie("ARTICLE_IMAGE.swf");
// loadARTICLE_IMAGE();
} else if (_root.checked = "IMAGE") {
_root.holder.loadMovie("IMAGE.swf");
// loadIMAGE();
} else if (_root.checked = "DOCUMENT") {
trace("no template for DOCUMENT set");
// _root.holder.loadMovie("DOCUMENT.swf");
addCount();
} else {
trace("error in actCheck");
};
};
// LOAD ARTICLE_IMAGE TEMPLATE AND PLAY -- CALLED BY TEMPLATE
function setARTICLE_IMAGE() {
var evalTitle = _root.templateStart + _root.templateCount + ".firstChild.nextSibling.firstChild.childNodes"
var evalSubtitle = _root.templateStart + _root.templateCount + ".firstChild.nextSibling.firstChild.nextSibling.chi ldNodes"
var evalIntro = _root.templateStart + _root.templateCount + ".firstChild.nextSibling.firstChild.nextSibling.nex tSibling.childNodes"
var evalText = _root.templateStart + _root.templateCount + ".firstChild.nextSibling.firstChild.nextSibling.nex tSibling.nextSibling.childNodes"
var evalImage = _root.templateStart + _root.templateCount + ".firstChild.nextSibling.firstChild.nextSibling.nex tSibling.nextSibling.nextSibling.firstChild.firstC hild.nextSibling.childNodes"
_root.holder.imageBox.loadMovie((eval(evalImage))) ;
_root.holder.titleBox.text = eval(evalTitle);
_root.holder.subtitleBox.text = eval(evalSubtitle);
_root.holder.introBox.text = eval(evalIntro);
_root.holder.textBox.text = eval(evalText);
set("_root.clockSheet", "1");
set("_root.countTimer", 1);
};
// LOAD IMAGE TEMPLATE AND PLAY
function setIMAGE() {
var evalImage = _root.templateStart + _root.templateCount + ".firstChild.nextSibling.firstChild.nextSibling.chi ldNodes"
_root.holder.imageBox.loadMovie((eval(evalImage))) ;
set("_root.clockSheet", "1");
set("_root.countTimer", 1);
};
// LOAD DOCUMENT TEMPLATE AND PLAY
function setDOCUMENT() {
// NO TEMPLATE SET
};
// timeSHEET
function timerSheet() {
if (_root.clockSheet == "1") {
if (_root.viewtime == _root.countTimer) {
clearInterval(timerClock);
trace("gelijk");
addCount();
} else {
trace("tellen");
set("_root.countTimer", _root.countTimer + 1);
};
};
};
// PREPARE RESTART
function addCount() {
set("_root.templateCount", _root.templateCount + ".nextSibling");
// trace(_root.templateCount);
restart();
};
// RESTART
function restart() {
_root.holder.unloadMovie();
checkTemplate();
};
// EIND PLAYER
stop();
In de in geladen swf's wordt setIMAGE() of setARTICLE_IMAGE() aangeroepen.
Echter gaat hij naar de tweede keer dat hij moet kijken wat voor template het is bij de functie actCheck gewoon door met het template ARTICLE_IMAGE en niet met IMAGE wat het in de .xml is. Wel laat hij IMAGE in als _root.checked. Er gaat dus iets fout bij de else if constructie in mijn ogen.
Maar wat?