To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here


A Flash Developer Resource Site

Go Back   Flash Kit Community Forums > Flash Help > Flash ActionScript

Reply
 
Thread Tools Search this Thread Display Modes
Old 10-14-2004, 04:04 AM   #1
JayGTR
Junior Member
 
Join Date: Jul 2004
Location: SA
Posts: 18
global Variables help! seriously.....

Hi all, I got a global variable that I want to see the output for using trace.
The problem is it comes out blank when I do trace. It gets it data from an xml file. I don't see how it could not get data. If I put the trace inside the function it outputs a value but not outside the function. Must I make the function global or something? Please help!

code:


_global.xValue;
_global.userInfo = new XML();
_global.userInfo.ignoreWhite = true;
_global.userInfo.load("http://localhost/gBook/userInfo.xml");
_global.userInfo.onLoad = function(success) {
if(success)
{
var root = this.firstChild
var b=0;
nodes = root.childNodes
for(var i=0; i<nodes.length; i++) {
subnodes = nodes[0].childNodes
subnodes2 = nodes[1].childNodes
subnodes3 = nodes[2].childNodes
_global.xValue = subnodes[0].firstChild.toString()
_global.xValueOne = subnodes2[0].firstChild.toString()
_global.xValueOne2 = subnodes3[0].firstChild.toString()
}
}

}
trace("Global x: " + _global.xValue);



EDIT: Changed code tags to [ as ] tags - jbum

Last edited by jbum; 10-14-2004 at 04:09 AM.
JayGTR is offline   Reply With Quote
Old 10-14-2004, 04:12 AM   #2
jbum
Senior Member
 
jbum's Avatar
 
Join Date: Feb 2004
Location: Los Angeles
Posts: 2,920
The problem is due to a misunderstanding of the order in which these lines execute.

At the time your trace() at the bottom executes, the onLoad() function has not yet executed, so _global.xValue has not been assigned from the XML yet.

The onLoad() function will execute later, and when it does, then _global.xValue will be defined.
__________________
jbum is offline   Reply With Quote
Old 10-14-2004, 04:30 AM   #3
MindWire
Member
 
Join Date: Oct 2003
Location: Colorado Springs
Posts: 82
So place your trace at the end of your onSuccess function
__________________
Justin Blough
MindWireMedia
(719) 659-8062
justin.blough@mindwiremedia.net
http://www.mindwiremedia.net
MindWire is offline   Reply With Quote
Old 10-14-2004, 09:28 AM   #4
JayGTR
Junior Member
 
Join Date: Jul 2004
Location: SA
Posts: 18
Resolved

Shot guys, works perfectly thanx.
JayGTR is offline   Reply With Quote
Reply

Go Back   Flash Kit Community Forums > Flash Help > Flash ActionScript

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 10:58 PM.


internet.commerce
Be a Commerce Partner
 »  »  »  »  »  »  »
 »  »  »  »  »  »
 

    

Acceptable Use Policy

internet.comMediabistrojusttechjobs.comGraphics.com

WebMediaBrands Corporate Info


Advertise | Newsletters | Feedback | Submit News

Legal Notices | Licensing | Permissions | Privacy Policy


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.