View Full Version : to XML or not to XML...
oluc
September 9th, 2009, 01:05 PM
Hello,
I am new to ActionScript 3 and CS4, and this may be an ignorant question but here it is.
I am loading a bunch of pictures into a sort of presentation in flash with interactivity. The picture loads and when the user presses next the picture slides to the left and comes forward but fades out on the edge and then text comes up explaining the picture. There are hundreds of pictures to do this for. I did an earlier version of this in Flash8 using XML. Now I am using Flash CS4 with AS3 - would you still do this with XML or is there a different way? Can I still make it fade out with xml?
Thankyou for any help!
IQAndreas
September 9th, 2009, 01:23 PM
Yes, the most common way nowdays is XML. That way, you don't have to hardcode anything, and it's the most human readable, which really helps in debugging errors.
Do you need any examples of doing it in AS3, or do you think you got it?
Just google "as3 XML slideshow tutorial" and you will get millions of results. :P
oluc
September 9th, 2009, 01:58 PM
Thanks man!
No, thats fine, I'm figuring it out now. Just wanted to make sure I was going in the right direction and not wasting time.
snickelfritz
September 9th, 2009, 02:55 PM
Use E4X methods for processing XML in AS3.
It's simpler and more powerful than the deprecated methods used in AS2 / XML.
oluc
September 9th, 2009, 08:46 PM
I ended up going to google and looked at "millions" of examples but I was not able to find one which did not have a URL as its reference or which did not type all of the code directly into flash. I am trying to do all of the AS external to my .fla file.
Could someone write me out an example of how they would load an .xml in an .as file that that have on their computer and not through the internet - or point me somewhere they know that would have this data?
Thanks!
kounoupi
September 10th, 2009, 07:58 AM
Quick, off the top of my head and not compile-tested, the idea is something like this:
suppose the xml file looks like
<xml>
<person>Joe</person>
<person>Nick</person>
</xml>
Then, after you import flash.net.URLLoader, load your XML in this manner:
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, xmlLoaded);
loader.load("definition.xml");
function xmlLoaded(e:Event){
var xml:XML = XML(e.target.data);
for (var person in xml.person){
trace person);
}
}
oluc
September 11th, 2009, 01:48 PM
Thank you.
Now, what if you were to do this not using a URL? Meaning the XML was located on your computer and not on the internet...
Krilnon
September 11th, 2009, 02:04 PM
You still use URLs and URLLoaders when loading content that is located on your computer.
oluc
September 11th, 2009, 02:46 PM
Oh, I see! And you would do that even if your flash content is not intended for the internet? Why is that? :h:
prone
September 11th, 2009, 03:23 PM
Hello!
I've researched a lot of examples on how to do this and I'm almost there. I actually got it to show up in the dynamic text box, but its also displaying my xml and css tags(The XML file structure). I know the xml and css files both work after testing them in my browser. Can you please assist me with fine-tuning this AS3 code. My XML file only has one node. Below is my AS3 code:
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, onLoadXML);
loader.load(new URLRequest("content.xml"));
function onLoadXML(e:Event):void
{
var xml:XML = new XML(e.target.data);
//trace(xml)
textBox.text = e.target.data
}
I just need it to read the content and follow the css code that's been attached to it.
Thanks!
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.