| |||||||
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) |
| Neuer User Registriert seit: Oct 2005
Beiträge: 2
| Fragen in normaler reihenfolge aus XML laden?
hi all ich habe folgendes script: Code: stop();
/**************************************
here we include the external file with
the list of our question and answers
**************************************/
/*************************************/
//toDisplay = 2; // how many question to display
// Random generation Questions
Object.prototype.nextAnswer = function(){
ranQuestion = random(domande.length)
for(var i = 0; i < domande.length; i++){
if(ranQuestion == tempArray[i]){
var prosegui = false;
nextAnswer();
break;
}
var prosegui = true;
}
if(prosegui){
tempArray.push(ranQuestion);
return ranQuestion;
}
}
// Remove the old points
Object.prototype.removePoints = function(what,keep){
for(var clips in _root.box){
if(_root.box[clips]._name.substring(0,_root.box[clips]._name.length -1) == what.substring(0,what.length-1) && _root.box[clips] != _root.box[what]){
_root.box[clips].point._visible = 0
}
}
}
// remove old answers
Object.prototype.removeAllAnswer = function(){
for(var answer in _root.box){
removeMovieClip(_root.box[answer])
}
}
// Build the Question
Object.prototype.buildQuestion = function() {
creaNuovoArray();
countAnswer++;
delete myChoice;
// call function to generate a random unique question
nextAnswer();
numero_domanda = "Question #" + countAnswer; // current Question
domanda = (domande[ranQuestion][0]) // Assing Question txt
removeAllAnswer();
// build answers;
for(var i = 0 ; i < domande[ranQuestion][2].length ; i++){
nextRisposta();
duplicateMovieClip("box.answer","answer"+i,i)
box["answer"+i].y_fin = answer0._y + (20*i)
box["answer"+i].txt = domande[ranQuestion][2][ranAns]
box["answer"+i].ca.cachild.txt = domande[ranQuestion][2][ranAns]
if(ranAns == domande[ranQuestion][1]){
box["answer"+i].thisChoice = true;
} else {
box["answer"+i].thisChoice = false;
}
}
box.answer._visible = 0
}
// Building random answers
function creaNuovoArray(){
delete tempRis;
tempRis = new Array();
}
Object.prototype.nextRisposta = function(){
ranAns = random(domande[ranQuestion][2].length)
for(var i = 0; i < domande[ranQuestion][2].length; i++){
if(ranAns == tempRis[i]){
var prosegui = false;
nextRisposta();
break;
}
var prosegui = true;
}
if(prosegui){
tempRis.push(ranAns);
return ranAns;
}
} danke Cobra |
| | |
| | #3 (permalink) |
| Neuer User Registriert seit: Oct 2005
Beiträge: 2
|
hi, die Fragen werden in einem späteren frame mit Code: timeStart = getTimer(); buildQuestion(); stop(); Zusätzlich wird dieses Actionscript Code: myxml=new XML();
myxml.ignoreWhite=true;
qtns=new Array();
myxml.onLoad=function(state){
if(state){
disp=Number(this.firstChild.attributes.total_interactions_per_play);
_global.logo=this.firstChild.attributes.logopath;
_global.companyname=this.firstChild.attributes.company_name;
_global.quiz_completion_message=this.firstChild.attributes.quiz_completion_message;
if(disp<=this.firstChild.childNodes.length){
toDisplay=disp;
}
else{
toDisplay=this.firstChild.childNodes.length;
}
for(i=0;i<this.firstChild.childNodes.length;i++){
qtns[i]=new Array();
qtns[i][0]=this.firstChild.childNodes[i].childNodes[0].firstChild.nodeValue;
qtns[i][1]=this.firstChild.childNodes[i].childNodes[1].firstChild.nodeValue;
qtns[i][2]=new Array();
for(j=0, k=0;j<this.firstChild.childNodes[i].childNodes.length;j++){
if(this.firstChild.childNodes[i].childNodes[j].nodeName=="option"){
qtns[i][2][k]=this.firstChild.childNodes[i].childNodes[j].firstChild.nodeValue;
k++;
}
}
}
domande=qtns;
curtain._visible=false;
int.play();
}
else{
curtain.message.text="Error loading items";
}
}
myxml.load("questions.xml");
curtain.message.text="generating quiz items"; Code: #include "questions.as" |
| | |
| | #4 (permalink) |
| Gast
Beiträge: n/a
|
Da das Script ziemlich umfangreich ist, empfehle ich dir erst einmal, das Script selbst Schritt für Schritt durchzugehen. Setz dir dazu bspw. ein paar trace-Befehle und lass dir im Testmodus damit die aktuellen Variableninhalte ausgeben. Besonders wichtig sind die random-Funktionen. Nützlich kann da auch die Verwendung des Einzelschrittsimulators in Verbindung mit dem Debugmodus sein. Wenn du dir sicher bist, welche Variablen über die Zufallsfunktionen gesetzt werden, kannst du dazu übergehen, statt der Zufallsfunktionen bspw. ein for-Schleife o.ä. zu nutzen, die dann einen Zähler hochzählt. |
|
![]() |
| Lesezeichen |
| Themen-Optionen | |
| Ansicht | |
| |