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

Displaying dynamic text from an xml file

Participant ,
Aug 02, 2013 Aug 02, 2013

I am attempting to display dynamic text from an external xml file. When I trace for the variable, all is well in the output window. But the text does not display in the published movie.

Here is my current code:

var myXML:XML;
var myLoader:URLLoader = new URLLoader();
myLoader.load(new URLRequest("AskAnExpert.xml"));
myLoader.addEventListener(Event.COMPLETE, processXML);
function processXML(e:Event):void {
myXML = new XML(e.target.data);

var topic1:String = myXML.TOPIC[0].TOPIC_NAME;

trace(topic1)

};

On-screen, I have a dynamic text field with an instance name of topic1. When I play the movie, the text does not display. I've tried various options of embedding the text and using _sans, but that doesn't seem to do the trick either. Help!

TOPICS
ActionScript
807
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

correct answers 1 Correct answer

LEGEND , Aug 02, 2013 Aug 02, 2013

You say you have a textfield with an instance name of topic1, but in your code you also declare a variable topic1 that you cast as a String.  The two cannot coexist.  If you really do have a textfield named topic1then assign the xml value to the textfield using...

topic1.text = myXML.TOPIC[0].TOPIC_NAME;

But do not use a varioable with the same name as the textfield

Translate
LEGEND ,
Aug 02, 2013 Aug 02, 2013

You say you have a textfield with an instance name of topic1, but in your code you also declare a variable topic1 that you cast as a String.  The two cannot coexist.  If you really do have a textfield named topic1then assign the xml value to the textfield using...

topic1.text = myXML.TOPIC[0].TOPIC_NAME;

But do not use a varioable with the same name as the 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
Participant ,
Aug 02, 2013 Aug 02, 2013

Thank you!

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
LEGEND ,
Aug 03, 2013 Aug 03, 2013
LATEST

You're welcome

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