Skip to main content
Participating Frequently
May 20, 2017
Question

Building a Quiz type application

  • May 20, 2017
  • 4 replies
  • 564 views

Greetings all. I'm new to animate, and have dabbled in flash in the past. I am working on a project in Animate CC 2017 that will read in a XML file that contains question and answers to a Quiz. On the first frame of the timeline I load the XML file and start process it. This is the XML file I am using:

<?xml version="1.0" encoding="utf-8"?>

<TEST>

<TITLE>Test over Training Aide: A-1</TITLE>

<DESCRIPTION>This test will check your understanding of the material covered in Training Aide: A-1</DESCRIPTION>

<POINTS TOTAL="10" PASSING="8" />

</TEST>

This is the code I have in frame on of the timeline:

var xmlTest:XML;

var urlLoader:URLLoader = new URLLoader();

urlLoader.load(new URLRequest("a-1.xml"));

urlLoader.addEventListener(Event.COMPLETE, processXML);

function processXML(e:Event):void {

      xmlTest = new XML(e.target.data);

      txtTitle.text = xmlTest.TITLE;

      txtDescription.text = xmlTest.DESCRIPTION;

      txtScore.text = "To pass you must get " + xmlTest.POINTS.@PASSING + " out of " + xmlTest.POINTS.@TOTAL + " correct.";

      gotoAndStop(2);

}

On Frame 2 I have 3 dynamic text area to display the information. Loaded from the XML file. It works as designed when I go to debug it in animate, but when I run it from a browser, all I get is a blank screen. When I run it in the browser I open the file form explorer by right click and clicking on open in Internet explorer. I am at a loss, any help would be greatly appreciates. Thank you

This topic has been closed for replies.

4 replies

Participating Frequently
May 21, 2017

Colin,

Thank you, it is working, at lease for now. Would it be okay if I contacted you if I run into something else? You have been a lot of help.

Thanks again,

Troy

BTW: If you are willing, I think it would be easier for me if we could use email in the future. It that is okay, my email it tlmarker@myomnitel.com.

Colin Holgate
Inspiring
May 21, 2017

I see all of the posts here (I'm a moderator too), so you can just try asking here first. That way anyone else with the same problem can learn from whatever the solution is.

But otherwise, yes, if there's something specific for me you can get in touch like I said in message 5.

Participating Frequently
May 21, 2017

Colin, I am sorry for being away for a little while, got to many oars in the water I guess. I was able to get the zip file on my Google Drive. This is the link it gave me to share the file: test.zip - Google Drive . At your convenience please take a look and see if you can help me. Thank you for your time.

Troy

Colin Holgate
Inspiring
May 21, 2017

Two things to try out:

In your function you gotoAndStop(2) after you have set the contents of the textfields, when the textfields may not exist yet (because the XML could have been loaded before leaving frame 1). Put a stop(); as the first line in the script, to keep it on frame 1, then in the function put the gotoAndStop(2) as the first line, so that you know you're where the textfields exist.

Also, read this discussion:

Latest version of Flash not working with local content. Can you confirm?

You will see that Flash Player 23 changed the security settings, so that it's normal for local SWFs to not be able to load local content. That discussion tells you where to go in order to add your test folder as a trusted location.

By the way, in Publish Settings there is a checkbox for creating an HTML Wrapper. If you use that you should get an HTML file that you can double-click to test, instead of having to manually open the SWF with IE.

Participating Frequently
May 20, 2017

Colin, I have the file zipped, where can I share them?

Colin Holgate
Inspiring
May 20, 2017

If you don't have a company server, or dropbox, or Google Drive, things like that, you could click on my icon and there should be a Message option to the right of the page.

I have a flight in the morning and will try to sleep soon, but I should be able to look at the files while I'm waiting for my plane to depart.

Colin Holgate
Inspiring
May 20, 2017

You could install the debug version of Flash Player to get more information about what's going wrong.

If you can use Firefox to test there are extensions that can let you see your Flash trace statements:

https://addons.mozilla.org/en-US/firefox/addon/flashtracer/

One thing to rule out first, normally you add the event listener before doing the action. Try this instead of what you have:

urlLoader.addEventListener(Event.COMPLETE, processXML);

urlLoader.load(new URLRequest("a-1.xml"));

Participating Frequently
May 20, 2017

Thank you for the reply. Firefox is not an option as the age I found says the plugin you mentioned does not work any more.

I also made the code change you mentioned, and nothing changed.

Thank you again.

Troy

Colin Holgate
Inspiring
May 20, 2017

Are you able to put a test online for us to try ourselves? Or make a zip of the FLA and xml files and post that somewhere.