Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Wheel of Fortune

Community Beginner ,
Sep 16, 2021 Sep 16, 2021

I would love to make a wheel of fortune puzzleboard.

How can I make one? Should I use a text file or XML?

9.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 25, 2021 Sep 25, 2021

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;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 27, 2021 Sep 27, 2021

Text won't display and every textbox is stacked

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 27, 2021 Sep 27, 2021

what code are you using?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 27, 2021 Sep 27, 2021

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();

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 28, 2021 Sep 28, 2021

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();

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 28, 2021 Sep 28, 2021

It works. I meant i wanted the textboxes shown horizontally.

Sorry about the confusion. The text works, though.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 28, 2021 Sep 28, 2021

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;

}

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 28, 2021 Sep 28, 2021

I keep getting this....

"Cannot access a property or method of a null object reference."

But, what part is null?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 28, 2021 Sep 28, 2021

what's the code on the line triggering the error.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 28, 2021 Sep 28, 2021

Same code above

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 28, 2021 Sep 28, 2021

Specifically this one,

"myAns.letter_txt.text = answers.attribute("text");"

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 29, 2021 Sep 29, 2021

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 01, 2021 Oct 01, 2021

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);
}
}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 03, 2021 Oct 03, 2021

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 03, 2021 Oct 03, 2021

I think I know what happened. I just traced it and all the letters are together to form the word.

I need them separate. That's why I was seeing one box. Other than that, I understand the x and y.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 03, 2021 Oct 03, 2021

 It worked! I finally got it!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 03, 2021 Oct 03, 2021
LATEST

One more thing, can you make columns? If so, how?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines