| |||||||
Du magst keine Werbung? Wir auch nicht!
Einfach registrieren und die Werbung ist weg. Diese Nachricht sehen nur nicht registrierte Nutzer.
![]() |
| | LinkBack | Themen-Optionen | Ansicht |
| | #1 (permalink) |
| °_° Registriert seit: May 2003 Ort: berlin
Beiträge: 197
|
hallo zusammen.. ich hab mir eine applikation auf basis von collin moocks quiz gebastelt, und hab nun das problem das es nur im flash player 6 läuft. Mit dem flash player 8 publiziert (actionscript1), wird zwar noch die anzahl der xml knoten korrekt ausgelesen und angezeigt, der inhalt der fragen und antworten aber nicht. vielleicht hat jemand von euch einen geistesblitz woran es liegen könnte.. Code: // stop the movie
stop();
// ### init main timeline variables
var displayTotal; // textfield for displaying user's final score
var totalCorrect = 0; // number of questions user answered correctly
var userAnswers = new Array(); // array containing the user's guesses
var currentQuestion = 0; // number of the question we're on
var questionsArray = new Array(); // array of question objects, built from xml doc
// ### load the external quiz.xml file into quizDoc. when it's done loading,
// process the xml by running the buildQuestionsArray function.
var quizDoc = new XML();
quizDoc.onLoad = buildQuestionsArray;
quizDoc.load("quiz.xml");
// ### builds an array of question objects based on the dom tree in quizDoc
function buildQuestionsArray () {
// first, strip unwanted whitespace nodes from the tree.
stripWhitespaceDoublePass(quizDoc);
// now assign a convenient reference to the root QUIZ node
var quizNode = quizDoc.firstChild;
// for each question node that is a child of the QUIZ node...
for(var i = 0; i < quizNode.childNodes.length; i++) {
// assign a convenient reference to the current question node
var thisQuestion = quizNode.childNodes[i];
// make an array of the text nodes from each CHOICE node
var choicesArray = new Array();
for(var j = 0; j < thisQuestion.childNodes.length; j++) {
var thisChoice = thisQuestion.childNodes[j];
choicesArray[j] = thisChoice.firstChild.nodeValue;
}
// construct a question object for each QUESTION node,
// and store it in questionsArray
questionsArray[i] = new Question (parseInt(thisQuestion.attributes.answer),
thisQuestion.attributes.text,
choicesArray);
}
// done loading and processing the quiz questions
loadMsg = "";
// begin the quiz
makeQuestion(currentQuestion);
}
// ### the Question constructor
function Question (correctAnswer, questionText, answers) {
this.correctAnswer = correctAnswer;
this.questionText = questionText;
this.answers = answers;
}
// ### function to render each question to the screen
function makeQuestion (currentQuestion) {
// clear the stage of the last question
questionClip.removeMovieClip();
// create and place the main question clip
attachMovie("questionTemplate", "questionClip", 0);
questionClip._x = 277;
questionClip._y = 205;
questionClip.qNum = "question\n>>" + (currentQuestion + 1);
questionClip.qText = ":: " + questionsArray[currentQuestion].questionText;
// create the individual answer clips in the question clip
for(var i = 0; i < questionsArray[currentQuestion].answers.length; i++) {
questionClip.attachMovie("answerTemplate","answer" + i, i);
questionClip["answer" + i]._y += 70 + (i * 15);
questionClip["answer" + i]._x -= 100;
questionClip["answer" + i].answerText = questionsArray[currentQuestion].answers[i];
}
}
// ### function to register the user's answers
function answer (choice) {
userAnswers.push(choice);
if (currentQuestion + 1 == questionsArray.length) {
questionClip.removeMovieClip();
gotoAndStop ("quizEnd");
} else {
makeQuestion(++currentQuestion);
}
}
// ### function to tally the user's score
function gradeUser() {
// count how many questions the user answered correctly
for(var i = 0; i < questionsArray.length; i++) {
if(userAnswers[i] == questionsArray[i].correctAnswer) {
totalCorrect++;
}
}
// show the user's score in an onscreen text field
displayTotal = totalCorrect + "/" + questionsArray.length;
}
// ### Strips whitespace nodes from an XML document
// ### by passing twice through each level in the tree
function stripWhitespaceDoublePass(XMLnode) {
// Loop through all the children of XMLnode
for (var i = 0; i < XMLnode.childNodes.length; i++) {
// If the current node is a text node...
if(XMLnode.childNodes[i].nodeType == 3) {
// ...check for any useful characters in the node.
var j = 0;
var emptyNode = true;
for(j = 0;j < XMLnode.childNodes[i].nodeValue.length; j++) {
// A useful character is anything over 32 (space, tab,
// new line, etc are all below).
if(XMLnode.childNodes[i].nodeValue.charCodeAt(j) > 32) {
emptyNode = false;
break;
}
}
// If no useful charaters were found, delete the node.
if(emptyNode) {
XMLnode.childNodes[i].removeNode();
}
}
}
// Now that all the whitespace nodes have been removed from XMLnode,
// call stripWhitespaceDoublePass on its remaining children.
for(var k = 0; k < XMLnode.childNodes.length; k++) {
stripWhitespaceDoublePass(XMLnode.childNodes[k]);
}
} wenn jemand es ausprobieren möchte , das quiz gibts hier quiz_xml_version)http://www.moock.org/asdg/codedepot/
__________________ mit maddin ueber allet ma reden... |
| | |
| | #2 (permalink) |
| Techniker Registriert seit: Sep 2003 Ort: 64807
Beiträge: 16.324
|
klassiker wie nicht deklarierte variablen oder gross/kleinschreibung erkenne ich beim drübersehen des veröffentlichten scriptes nicht. geh dein programm mit dem debugger durch (siehe meine signatur), dann solltest du erkennen, wo was nicht stimmt.
__________________ die ultimative antwort auf alle programmierfragen: der debugger mfg h.g.seib www.SeibsProgrammLaden.de Geändert von hgseib (18-02-2007 um 10:27 Uhr) |
| | |
| | #3 (permalink) |
| °_° Registriert seit: May 2003 Ort: berlin
Beiträge: 197
|
debugger hat insofern was gebracht als ich jetzt weiß das die variablen in der flash 8 publizerten version leer(undefined) sind und mit flash 6 enthalten sie das was sie sollen. also mal cleverer gefragt: Gibt es beim laden von xml daten eine syntax die sich verändert hat? In beiden versionen publishe ich ja mit actionscript1 auf strikte typisierung müsste ich demnach ja keine rücksicht nehmen. was hat sich noch verändert von fp6 zu fp8 (fp7 geht auch nicht)?
__________________ mit maddin ueber allet ma reden... |
| | |
| | #4 (permalink) | |
| Techniker Registriert seit: Sep 2003 Ort: 64807
Beiträge: 16.324
| Zitat:
function buildQuestionsArray (ok) { <-- hier wird ein wert übergeben, schon immer trace(this) <-- zumindestens hier musst du etwas sehen if (ok) { ... ergänze mal: var quizDoc = new XML(); quizDoc.ignoreWhite=true; mit variablen deklarieren meinte ich mehr sowas zahl+=13; ohne vorher ein zahl=0; zu deklarieren und nicht die typisierung.
__________________ die ultimative antwort auf alle programmierfragen: der debugger mfg h.g.seib www.SeibsProgrammLaden.de Geändert von hgseib (18-02-2007 um 18:58 Uhr) | |
| | |
| | #5 (permalink) |
| °_° Registriert seit: May 2003 Ort: berlin
Beiträge: 197
|
ignorewhite half leider nicht.. die inhalte des xmlfiles wurden korrekt geladen... nur in der funktion sind alle trace versuche undefined Code: // ### function to render each question to the screen
function makeQuestion (currentQuestion) {
// clear the stage of the last question
questionClip.removeMovieClip();
// create and place the main question clip
attachMovie("questionTemplate", "questionClip", 0);
questionClip._x = 277;
questionClip._y = 205;
questionClip.qNum = "question\n>>" + (currentQuestion + 1);
questionClip.qText = ":: " + questionsArray[currentQuestion].questionText;
// create the individual answer clips in the question clip
for(var i = 0; i < questionsArray[currentQuestion].answers.length; i++) {
questionClip.attachMovie("answerTemplate","answer" + i, i);
questionClip["answer" + i]._y += 70 + (i * 15);
questionClip["answer" + i]._x -= 100;
questionClip["answer" + i].answerText = questionsArray[currentQuestion].answers[i];
}
} ich meine damit: die ursache dafür wird mir nicht klar. und dabei bin ich wieder beim kernpunkt, was denn eigentlich der wesentliche unterschied in fp6 und bspw. fp7 ist. vielleicht lässt sich ja aus den wesentlichen unterschieden viel eher die fehlequelle ausmachen? gruss martin
__________________ mit maddin ueber allet ma reden... |
| | |
![]() |
| Lesezeichen |
| Themen-Optionen | |
| Ansicht | |
| |