Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 718051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:28:57+00:00 2026-05-14T05:28:57+00:00

Flash receives the XML, but the values are wrong. How do I fix this?

  • 0

Flash receives the XML, but the values are wrong. How do I fix this?

Problem
I can see the XML loaded with no errors, but my output is way off. It’s as though it’s not receiving any values. Numbers in the output window and animation move rapidly. The Flash file runs as if it’s variables where set to zero. I changed the order of my code, but that didn’t help with this. Please explain how I can correct this.

SWF

//load xml
var myXML:XML;
var myLoader:URLLoader = new URLLoader();
myLoader.load(new URLRequest("xml.xml"));
myLoader.addEventListener(Event.COMPLETE, processXML);
//parse XML
function processXML(e:Event):void {
myXML = new XML(e.target.data);
trace(myXML);
//receive values from XML
delay = parseInt(myXML.DELAY.text());
trace(delay);   
repeat = parseInt(myXML.REPEAT.text());
trace(repeat);  
}
//variables
var delay:uint = 0;
var repeat:uint = 0;
//timer and event
var timer:Timer = new Timer(uint(delay),uint(repeat));
timer.addEventListener(TimerEvent.TIMER, countdown);
//counter
function countdown(event:TimerEvent) {
myText.text = String(0 + timer.currentCount);
trace(0 + timer.currentCount);
}
timer.start();

XML

<?xml version="1.0" encoding="utf-8"?>
<SESSION>
<DELAY TITLE="starting position">1000</DELAY>
<REPEAT TITLE="starting position">60</REPEAT>
</SESSION>

my output

1
<SESSION>
  <DELAY TITLE="starting position">1000</DELAY>
  <REPEAT TITLE="starting position">60</REPEAT>
</SESSION>
1000
60
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101

your problem is that you’re calling myLoader.load() and adding an event listener to wait for the xml to finish loading, but you’re then immediately setting var delay:uint = 0; and var repeat:uint = 0; and starting the timer. you can see this in your results by the 1, XML, 2, 3, 4 output. the load call is asynchronous so it returns immediately. you need to wait until your processXML function is called before proceeding to the next step.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T05:28:57+00:00Added an answer on May 14, 2026 at 5:28 am

    you need to re-order your code a touch. you’re not waiting for the xml to finish loading before you try and start the timer. the easiest way to do this is to put it in the processXML method, like so.

    //load xml
    var myXML:XML;
    var myLoader:URLLoader = new URLLoader();
    
    myLoader.load(new URLRequest("xml.xml"));
    myLoader.addEventListener(Event.COMPLETE, processXML);
    
    var timer:Timer;
    
    //parse XML
    function processXML(e:Event):void {
      myXML = new XML(e.target.data);
      trace(myXML);
      //receive values from XML
      var delay:uint = parseInt(myXML.DELAY.text());
      trace(delay);   
      var repeat:uint = parseInt(myXML.REPEAT.text());
      trace(repeat);  
    
      //timer and event
      timer = new Timer(delay,repeat);
      timer.addEventListener(TimerEvent.TIMER, countdown);
      timer.start();
    }
    
    function countdown(event:TimerEvent) {
      myText.text = String(0 + timer.currentCount);
      trace(0 + timer.currentCount);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 357k
  • Answers 357k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The other answers are correct. Here is some code you… May 14, 2026 at 9:40 am
  • Editorial Team
    Editorial Team added an answer you ruin the noConflict concept by reassigning the jquery to… May 14, 2026 at 9:40 am
  • Editorial Team
    Editorial Team added an answer If you get that particular error, you don't actually have… May 14, 2026 at 9:40 am

Related Questions

No related questions found

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.