Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 11-03-2007, 07:46 PM   #1
ferrarih
Registered User
 
Join Date: Oct 2007
Posts: 8
Red face Tracing array from a xml doesn`t work

I`m trying to trace the pics[1] but I just get undefined when it`s out of the doMenu function. Do you know how to fix it?


var xmlDoc:XML = new XML();
System.useCodepage = true;
xmlDoc.ignoreWhite = true;

xmlDoc.onLoad = function(ok:Boolean) {
if (ok) {
doMenu(this);
} else {
trace("XML did not load");
}
};

xmlDoc.load("images.xml");

function doMenu(xml:XML) {
var num:Number = xml.firstChild.childNodes.length;
pics = new Array();
for (var i = 0; i < num; i++) {
pics[i] = xml.firstChild.childNodes[i].attributes.image;
}
trace(pics[1]); <<< this works
}
trace(pics[1]); <<< this one doesn`t
ferrarih is offline   Reply With Quote
Old 11-03-2007, 09:16 PM   #2
wvxvw
Holosuit User
 
wvxvw's Avatar
 
Join Date: Oct 2006
Location: Tel Aviv
Posts: 4,301
Send a message via ICQ to wvxvw
Default

The code execution and actual event of loading XML are asinchroneous. So, the last trace will be called before xmlDoc.onLoad().
wvxvw is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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 Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
xml and css: cant get custom class to work on links roystik ActionScript 2.0 0 08-16-2007 08:37 AM
LOADING XML INTO ARRAY for use in movie AndiG ActionScript 2.0 8 05-17-2007 06:09 PM
Array from XML alflashy ActionScript 2.0 6 05-11-2007 04:02 PM
help with XML structure and tracing in Flash. lariat1997 ActionScript 2.0 0 02-19-2007 07:14 PM
problem creating mc instance names inside a function jasonyen ActionScript 2.0 10 12-08-2004 01:01 AM


All times are GMT. The time now is 05:45 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.