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 17, 2021 Sep 17, 2021

xml is easier to parse.

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 17, 2021 Sep 17, 2021

Can you show me how to?

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 17, 2021 Sep 17, 2021

How can I parse the XML data in Animate CC?

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 17, 2021 Sep 17, 2021

var r = new XMLHttpRequest();
r.open("GET", "your xml file.xml", true);
r.addEventListener("load", rF);
r.send();

function rF(e) {
parser = new DOMParser();
var xml = parser.parseFromString(e.target.response, "text/xml");

// the exact parsing depends on the structure of the loaded xml file.
alert(xml.getElementsByTagName("a tag name")[0].childNodes[0].nodeValue);
}

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 17, 2021 Sep 17, 2021

Thanks. Will this work with the Jeopardy game also?

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 17, 2021 Sep 17, 2021

I got errors when I tried it. Can you possibly break it down for me?

This is the xml file I'm 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 Expert ,
Sep 18, 2021 Sep 18, 2021

what errors and 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 18, 2021 Sep 18, 2021

I used the code above. Next I tried to use the URLLoader code, but when I tried it, nothing showed up.

Am I doing something wrong?

This is the code I'm using now...

var myXML:XML = new XML();
var myXMLURL:URLRequest = new URLRequest("puzzle1.xml");
var myLoader:URLLoader = new URLLoader(myXMLURL);
myLoader.addEventListener("complete", xmlLoaded);

function xmlLoaded(e:Event):void{
myXML = XML(myLoader.data);

var myAnswers:Sprite = new Sprite;
myAnswers.name = "answers";
answers_mc.addChild(myAnswers);

var answers:XMLList = myXML.children();
var numAnswers:int = answers.length();
var i:int = 0;

for(i=0; i<numAnswers; i++){
var myAns:Answer = new Answer();
myAns.answer_txt = answers.attributes("name");
}
}

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 19, 2021 Sep 19, 2021

are you creating an as3 project or html5/canvas?

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 19, 2021 Sep 19, 2021

I am creating an as3 project

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 20, 2021 Sep 20, 2021

you probably want:

 

var myXML:XML = new XML();
var myXMLURL:URLRequest = new URLRequest("puzzle1.xml");
var myLoader:URLLoader = new URLLoader(myXMLURL);
myLoader.addEventListener("complete", xmlLoaded);

function xmlLoaded(e:Event):void{
myXML = XML(myLoader.data);

var myAnswers:Sprite = new Sprite;
myAnswers.name = "answers";
answers_mc.addChild(myAnswers);

var answers:XMLList = myXML.children()[0].children();
var numAnswers:int = answers.length();
var i:int = 0;

for(i=0; i<numAnswers; i++){
var myAns:Answer = new Answer();
myAns.answer_txt = answers[i]);
}
}

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 20, 2021 Sep 20, 2021

Tried it, but it says "Type Coercion failed: cannot convert XML@40eafff23a1 to flash.text.TextField."

What should I do?

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 20, 2021 Sep 20, 2021

use:

 

for(i=0; i<numAnswers; i++){
var myAns:Answer = new Answer();
myAns.answer_txt.text += answers[i].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 21, 2021 Sep 21, 2021

Now it's saying "A term is undefined and has no properties."

I think it has something to do with the XML document. What should I do now?

 

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 numAnswers:int = letters.length();
var i:int = 0;

for(i=0; i<numAnswers; i++){
var myAns:Answer = new Answer();
myAns.answer_txt.text += letters[i].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 21, 2021 Sep 21, 2021
 
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 21, 2021 Sep 21, 2021

click file>publish settings>tick "enable debugging">retest.

 

the error message will reappear with the problematic line number.  if that doesn't make the solution obvious to you, indicate 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 ,
Sep 21, 2021 Sep 21, 2021

Well, I finally figured out a formula. How can I do the addChild effect?

 

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);
letter_txt.text = puzzle.item.answers.answer[0];
trace("Data loaded.");
}

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 22, 2021 Sep 22, 2021

 by the "addChild effect", do you mean you want to display all your answers in a separate textfield?:

 

 

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 22, 2021 Sep 22, 2021

Yes I do.

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 23, 2021 Sep 23, 2021

do you have those textfields on stage or are you going to create them dynamically (by having a textfield in a movieclip and that movieclip has a linkage id)?

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 23, 2021 Sep 23, 2021

create them dynamically

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 23, 2021 Sep 23, 2021

textfield in a movieclip and the movieclip has a linkage id

can you show me how to do textfields on stage as well?

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 23, 2021 Sep 23, 2021

create a new movieclip with a textfield tf.  assign class name TF_MC.

 

var myXML: XML = new XML();
var myXMLURL: URLRequest = new URLRequest("puzzle1.xml");
var myLoader: URLLoader = new URLLoader(myXMLURL);
myLoader.addEventListener("complete", xmlLoaded);

function xmlLoaded(e: Event): void {
myXML = XML(e.target.data);

var answers: XMLList = myXML.children()[0].children();

var numAnswers: int = answers.length();
var i: int = 0;
var nextY = 0;

for(i = 0; i < numAnswers; i++) {
var tf_mc = new TF_MC();
addChild(tf_mc);
tf_mc.name = "tf_"+i;
tf_mc.tf.text = answers[i].toString();
tf_mc.x = 20
tf_mc.y = nextY;
nextY += tf_mc.height;
}
}

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 23, 2021 Sep 23, 2021

It worked! However, one only text box showed up.

var myXML: XML = new XML();
var myXMLURL: URLRequest = new URLRequest("puzzle.xml");
var myLoader: URLLoader = new URLLoader(myXMLURL);
myLoader.addEventListener("complete", xmlLoaded);

function xmlLoaded(e: Event): void {
myXML = XML(e.target.data);

var myAnswers:Sprite = new Sprite();
myAnswers.name = "answers";
answers_mc.addChild(myAnswers);

var answers: XMLList = myXML.children();
var numAnswers: int = answers.length();
var i: int = 0;

for(i = 0; i < numAnswers; i++) {
var myAns:Answer = new Answer();
myAnswers.addChild(myAns);
myAns.x = 300;
myAns.y = 400;
}
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