Skip to main content
Known Participant
November 20, 2021
Question

Family Feud

  • November 20, 2021
  • 1 reply
  • 596 views

I have a textfile I'd like to use to make Family Feud.

Is there anyway to split the text file and turn in into an array?

What should I do?

    This topic has been closed for replies.

    1 reply

    Colin Holgate
    Inspiring
    November 21, 2021

    If this is for ActionScript, you could look into using XML for the text, and then read this article to see how you can read in the text and access it just like it is an array:

    https://help.adobe.com/en_US/as3/dev/WS5b3ccc516d4fbf351e63e3d118a9b90204-7e6b.html

    If this is for HTML5 Canvas, you could change the text to be more like this:

    var t = "GHOSTS,UFOS,TOOTH FAIRY,SANTA CLAUS,ALIENS";
    var a = t.split(",");
    alert(a[3]);

    In that example the answers were made into an array with the split() function, and then looking at entry '3' gives SANTA CLAUS (arrays start at zero).

    Known Participant
    November 25, 2021

    Ok, to make the questions, I need to create an XML data in AS3.

    So far, I got this part. But, I need to know how to save it using FileReference.

     

    function createXML():void{
    var obj:XML = new XML(<answers></answers>);
    var node:XML = new XML(<answer1></answer1>);
    node.appendChild(<text>(ad1.text)</text>);
    node.appendChild(<points>(pd1.text)</points>);
    obj.appendChild(node);
    }

     

     

    Colin Holgate
    Inspiring
    November 25, 2021

    I was thinking that you would use a text editor to make the XML file, and read that in with AS3.