Copy link to clipboard
Copied
I would love to make a wheel of fortune puzzleboard.
How can I make one? Should I use a text file or XML?
Copy link to clipboard
Copied
all your textfields are on-top of each other. check my code
tf_mc.x = 20
tf_mc.y = nextY;
nextY += tf_mc.height;
and fix yours
myAns.x = 300;
myAns.y = 400;
Copy link to clipboard
Copied
Text won't display and every textbox is stacked
Copy link to clipboard
Copied
what code are you using?
Copy link to clipboard
Copied
var xmlRequest:URLRequest = new URLRequest("puzzle.xml");
var myLoader:URLLoader = new URLLoader(xmlRequest);
var puzzle:XML;
myLoader.addEventListener("complete", xmlLoaded);
function xmlLoaded(e: Event): void {
puzzle = XML(e.target.data);
var myAnswers:Sprite = new Sprite();
myAnswers.name = "answers";
answers_mc.addChild(myAnswers);
var answers: XMLList = puzzle.children()[0].children();
var numAnswers: int = answers.length();
var i: int = 0;
var nextY = 0;
for(i = 0; i < numAnswers; i++) {
var myAns:Answer = new Answer();
myAns.letter_txt.text = answers.attribute("text");
if(numAnswers>5){
myAns.x = 50;
myAns.y = nextY;
nextY += myAns.height;
}
myAnswers.addChild(myAns);
}
myAns.name = "text" + (i+1).toString();
}
Copy link to clipboard
Copied
what's the trace show:
var xmlRequest:URLRequest = new URLRequest("puzzle.xml");
var myLoader:URLLoader = new URLLoader(xmlRequest);
var puzzle:XML;
myLoader.addEventListener("complete", xmlLoaded);
function xmlLoaded(e: Event): void {
puzzle = XML(e.target.data);
var myAnswers:Sprite = new Sprite();
myAnswers.name = "answers";
answers_mc.addChild(myAnswers);
var answers: XMLList = puzzle.children()[0].children();
var numAnswers: int = answers.length();
var i: int = 0;
var nextY = 0;
for(i = 0; i < numAnswers; i++) {
var myAns:Answer = new Answer();
myAns.letter_txt.text = answers.attribute("text");
if(numAnswers>5){
myAns.x = 50;
myAns.y = nextY;
nextY += myAns.height;
trace(i,myAns.letter_txt.text);
}
myAnswers.addChild(myAns);
}
myAns.name = "text" + (i+1).toString();
}
Copy link to clipboard
Copied
It works. I meant i wanted the textboxes shown horizontally.
Sorry about the confusion. The text works, though.
Copy link to clipboard
Copied
use:
var xmlRequest:URLRequest = new URLRequest("puzzle.xml");
var myLoader:URLLoader = new URLLoader(xmlRequest);
var puzzle:XML;
myLoader.addEventListener("complete", xmlLoaded);
function xmlLoaded(e: Event): void {
puzzle = XML(e.target.data);
var myAnswers:Sprite = new Sprite();
myAnswers.name = "answers";
answers_mc.addChild(myAnswers);
var answers: XMLList = puzzle.children()[0].children();
var numAnswers: int = answers.length();
var i: int = 0;
var:int nextX = 0; // or wherever
var:int nextY = 0; // or wherever
var:int letter_spacing = 5; // or whatever
var:int leading = 30; // or whatever
for(i = 0; i < numAnswers; i++) {
var myAns:Answer = new Answer();
myAns.name = "text" + (i+1).toString();
myAnswers.addChild(myAns);
myAns.letter_txt.text = answers.attribute("text");
myAns.letter_txt.autoSize = "left";
myAns.x = nextX;
if(myAns.x+myAns.width>Stage.stageWidth){
nextY+=leading;
nextX = 0; // or whatever
}
myAns.y = nextY;
nextX += myAns.width+letter_spacing;
}
}
Copy link to clipboard
Copied
Copy link to clipboard
Copied
what's the code on the line triggering the error.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Specifically this one,
"myAns.letter_txt.text = answers.attribute("text");"
Copy link to clipboard
Copied
either myAns.letter_txt or answers don't exist.
to find which use:
trace(myAns.letter_txt.);
trace(answers)
above the problematic line of code.
Copy link to clipboard
Copied
Fixed the text problem. But, it's still showing only one text.
var xmlRequest:URLRequest = new URLRequest("puzzle.xml");
var myLoader:URLLoader = new URLLoader(xmlRequest);
var puzzle:XML;
myLoader.addEventListener("complete", xmlLoaded);
function xmlLoaded(e: Event): void {
puzzle = XML(myLoader.data);
var myAnswers:Sprite = new Sprite();
myAnswers.name = "letters";
answers_mc.addChild(myAnswers);
var letters: XMLList = puzzle.children();
var numLetters: int = letters.length();
var i: int = 0;
for(i = 0; i < numLetters; i++) {
var myAns:Answer = new Answer;
myAns.letter_txt.text = puzzle[i].item.letter.@text;
myAns.letter_txt.autoSize = "left";
myAns.x = 200;
myAns.y = 300;
myAns.name = "letter" + (i+1).toString();
myAnswers.addChild(myAns);
}
}
Copy link to clipboard
Copied
this is, at least, the third time you've made the same error. your textfields are all overlapping. ie, fix:
myAns.x = 200;
myAns.y = 300;
i think i've shown you how to do that by arranging them vertically and by arranging them horizontally. what is it that you don't understand about how to assign x and y properties to arrange objects on stage?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
It worked! I finally got it!
Copy link to clipboard
Copied