all groups > flash data integration > november 2005 >
You're in the

flash data integration

group:

Problem loading XML


Problem loading XML MaveK
11/9/2005 12:00:00 AM
flash data integration: Good evening all. I am new to Flash and have just been learning a lot over the
last couple days. I bought a pre-made fla file and am trying to customize it.
This will be a little difficult to explain to please bear with me.

The fla file has a TON of buttons and a few "Symbol Definitions". I am editing
a key frame actionscript on one of the "Definitions". I add the following lines
to load my XML file but nothing happens.

trace("test");
var OrgsXML:XML = new XML();
OrgsXML.ignoreWhite = true;
OrgsXML.onLoad = function(success:Boolean) {
if (success) {
Trace("Status: "+success);
} else {
trace("error")
}
};
OrgsXML.load("states.xml");

This exact code works on a blank fla file as expected but nothing happens in
the more complex file that I am trying to customize. I know that this is not a
lot of information and I am sorry that I can't explain it better. I have tried
moving this code to different key frames but I can never get the trace("Status:
"+success); or error to come up and I can not access any of the XML data that
should be there.

Perhaps I need an initial course on scope and calling functions. Thanks for
you help and I will try to answer any questions to the best of my ability.

Re: Problem loading XML MaveK
11/12/2005 12:25:25 AM
Ok, I have isolated the problem to the XML variable data type. If I define the
var OrgsXML:XML with the XML data type then the variable is "undefined" but if
I leave out the XML data type then at least the file loads. Unfortunately the
onLoad function returns the "error" instead of the sucess.

First question: Why is the XML datat ype causing the variable to be undefined?

Second question: Why is the XML onLoad function returning an error? (Does it
have anything to do with my XML file?)

Third question: Is there a standard XML format that flash is expecting?
(Macromedia has presented several diferent XML exammples.)


<?xml version="1.0" encoding="iso-8859-1"?>
<STATES>
<ORG STATE="OR"
ACRONYM="OCEANetwork"
URL="http://www.oceanetwork.org" />
<ORG STATE="VA"
ACRONYM="HEAV"
NAME="Home Educators Assocation of Virginia"
URL="http://www.heav.org" />
<ORG STATE="IA"
ACRONYM="IAHE"
NAME="Indiana Assocation of Home Educators"
URL="http://www.inhomeeducators.org" />
</STATES>

Re: Problem loading XML Motion Maker
11/12/2005 2:33:43 PM
[quoted text, click to view]
"+success);

[quoted text, click to view]

trace is not a capitalized as Trace.

--
Lon Hosford
www.lonhosford.com
May many happy bits flow your way!
[quoted text, click to view]
Good evening all. I am new to Flash and have just been learning a lot over
the
last couple days. I bought a pre-made fla file and am trying to customize
it.
This will be a little difficult to explain to please bear with me.

The fla file has a TON of buttons and a few "Symbol Definitions". I am
editing
a key frame actionscript on one of the "Definitions". I add the following
lines
to load my XML file but nothing happens.

trace("test");
var OrgsXML:XML = new XML();
OrgsXML.ignoreWhite = true;
OrgsXML.onLoad = function(success:Boolean) {
if (success) {
Trace("Status: "+success);
} else {
trace("error")
}
};
OrgsXML.load("states.xml");

This exact code works on a blank fla file as expected but nothing happens
in
the more complex file that I am trying to customize. I know that this is
not a
lot of information and I am sorry that I can't explain it better. I have
tried
moving this code to different key frames but I can never get the
trace("Status:
"+success); or error to come up and I can not access any of the XML data
that
should be there.

Perhaps I need an initial course on scope and calling functions. Thanks for
you help and I will try to answer any questions to the best of my ability.

Re: Problem loading XML Motion Maker
11/12/2005 2:45:26 PM
Q1. Try this
var OrgsXML:XML = new XML();
trace (typeof(OrgsXML))

Q2. XML.load will return an error in the output window if it cannot find the
file. As well the success argument is false.

Q3. I alway add the <?xml version='1.0' encoding='UTF-8' ?> but you can
leave it out. Make sure there are no line breaks in the xml file.
<?xml version='1.0' encoding='UTF-8' ?><datapacket><message>Hello
World!</message></datapacket>'


--
Lon Hosford
www.lonhosford.com
May many happy bits flow your way!
[quoted text, click to view]
Ok, I have isolated the problem to the XML variable data type. If I define
the
var OrgsXML:XML with the XML data type then the variable is "undefined" but
if
I leave out the XML data type then at least the file loads. Unfortunately
the
onLoad function returns the "error" instead of the sucess.

First question: Why is the XML datat ype causing the variable to be
undefined?

Second question: Why is the XML onLoad function returning an error? (Does
it
have anything to do with my XML file?)

Third question: Is there a standard XML format that flash is expecting?
(Macromedia has presented several diferent XML exammples.)


<?xml version="1.0" encoding="iso-8859-1"?>
<STATES>
<ORG STATE="OR"
ACRONYM="OCEANetwork"
URL="http://www.oceanetwork.org" />
<ORG STATE="VA"
ACRONYM="HEAV"
NAME="Home Educators Assocation of Virginia"
URL="http://www.heav.org" />
<ORG STATE="IA"
ACRONYM="IAHE"
NAME="Indiana Assocation of Home Educators"
URL="http://www.inhomeeducators.org" />
</STATES>

Re: Problem loading XML Motion Maker
11/12/2005 4:23:43 PM
Just to be sure the undefined is coming from this line I modified it

var OrgsXML:XML = new XML();
trace ("typeof(OrgsXML) = " + typeof(OrgsXML))

Also try placing the code in a brand new Flash movie on the first frame.

Not sure if this would do it but check to see if you are using AS 2.0 in
File->Publish Settings->Flash Tab



--
Lon Hosford
www.lonhosford.com
May many happy bits flow your way!
[quoted text, click to view]
Originally posted by: Newsgroup User
Q1. Try this
var OrgsXML:XML = new XML();
trace (typeof(OrgsXML))


Still get "undefined"

Re: Problem loading XML MaveK
11/12/2005 8:47:03 PM
Originally posted by: Newsgroup User
Q1. Try this
var OrgsXML:XML = new XML();
trace (typeof(OrgsXML))


Still get "undefined"

Re: Problem loading XML Motion Maker
11/12/2005 9:09:34 PM
XML is in Flash 5.

AS 2.0 is for using data types like this

var myXML:XML


in AS 1.0
you are restricted to
var myXML

--
Lon Hosford
www.lonhosford.com
May many happy bits flow your way!
[quoted text, click to view]
OK, this was a new-be mistake...

XML is a ActionScript 2 function. Right?

I swiched it to ActionScript 2 and it works! Thanks!

Re: Problem loading XML MaveK
11/12/2005 10:39:28 PM
OK, this was a new-be mistake...

XML is a ActionScript 2 function. Right?

AddThis Social Bookmark Button