How to use XML.load() for Kongregate

13 posts

Flag Post

I created a game a year ago that I used XML.load() to load in level files so that 1) I didn’t have to hard code them, 2) use the OOP abilities to control enemies, and 3) be able to create new levels without needing my .fla and recompiling a new .swf.

However, it seems that XML.load() can only load XML files on the same server as the .swf, which means that I’d need to upload the level files to Kongregate, except…1) I can’t upload XML files and 2) I can only upload one.

How do I get around this?

 
Flag Post

Did you try zipping the files and uploading them?

Also, you can leave them on your own server; you just need to create a cross domain policy file on your server to let Flash know its ok to load that data.

 
Flag Post

Thanks for the link (despite it not actually going to the page, I found it). Lets see if it works. XML stuff in Flash is a b*tch (and beyond the scope of the class I built the game in). Does wonders, yes, but not easy.

Nope, didn’t work. Now the code thinks it loads the XML but doesn’t, meaning it doesn’t give me the error “failed to load level file” and instead runs as if the XML file was blank.

Actionscript:


function getLevel() {
System.security.loadPolicyFile(“http://www.pages.drexel.edu/~mmj29/DIGM%20265/crossdomain.xml”);
levelXML = new XML;
levelXML.load(“http://www.pages.drexel.edu/~mmj29/DIGM%20265/level”_global.Level“.xml”);
}

crossdomain.xml:
<?xml version=“1.0”?>
<!-- http://www.foo.com/crossdomain.xml -->
<cross-domain-policy>
<allow-access-from />
<allow-access-from />

</cross-domain-policy>

 
Flag Post

Bloody heck, these forums suck (no offence to Kongregate). Ew…..I mean I know not using a [code] tag messes things up, but that’s just HORRIBLE!
Also not having BBC is ick.

 
Flag Post

Hey why don’t you try making a game that doesn’t need XML to work properly. XML is useful for larger Web site projects, but not exactly necessary for a game. Don’t fault Kong because you can’t write a freakin’ HTML tag… it’s not rocket science bro.

 
Flag Post

If it doesnt work then you’re not doing something right since its entirely possible. Check your policy file and read up more on security as well. It is true that XML can be a dog, but thats why a good developer writes components and classes to do the work easier. AS 3.0 has been heavily revised in the XML area as well, so its much easier in Flash 9.

XML is useful for larger Web site projects, but not exactly necessary for a game.

Actually, its great for games. I use it for most of my games and it makes certain tasks a lot easier (clients like it as well). But thats since I have custom components to help with the parsing. But ya, for a project like this you likely want to avoid it.

In regard to the forums, it uses Textile formatting with some html support, and I fixed the post so it works.

 
Flag Post

Read this entry in the Flash Help, LiveDocs version: http://livedocs.adobe.com/flash/mx2004/main_7_2/wwhelp/wwhimpl/common/html/wwhelp.htm?href=00001750.html

That might help for XML files, otherwise read in the Help or a reference book for information regarding the security model implemented in Flash.

 
Flag Post

Neutrino64:
I’ve never ever seen a forum that uses HTML before. Ever. Ussually because you can do things with HTML that can seriously fuck up the forum, it’s the exact reason BBC (Buliten Board Code) was created and UNIVERSALY adopted. As or Textile formatting, what the heck is that? I’ve never heard of it (and neither has google).
I’d also be better at making the posts if the Help on this site had anything on the formatting (all I see is the stuff to the right of this window, which doesn’t help me (though the “new topic” window lacks even that much).

Miahmiah:
Thanks for the link. However, System.security.allowDomain() isn’t what I need. It allows objects in the specified domain to access the domain CALLING System.security.allowDomain(): Because MovieA contains the allowDomain() command, MovieB can access the objects and variables in MovieA. Not what I need. Not to mention “Flash Player 6; behavior changed in Flash Player 7.”

I’ll poke at it some more. It seems to me that my System.security.loadPolicyFile() is either in the wrong place or used incorrectly. I’ve modifed the crossdomain file to allow all access.

 
Flag Post

Textile Info

 
Flag Post


bq. I’ve never ever seen a forum that uses HTML before


I have. Its always limited tags.

As or Textile formatting, what the heck is that? I’ve never heard of it (and neither has google).


Its a formatting that a lot of “Web 2.0” sites use. Google has heard of it, as several of the links on the first page are http://en.wikipedia.org/wiki/Textile_(markup_language) and http://www.textism.com/tools/textile/ and http://hobix.com/textile/. It is also commonly used in business products like basecamp.

Also remember, the site is in BETA, and yes, the forums lack much at this point. Additionally, if you had read the sticky at the top of this forum you would know how to format code for the forum. It uses html tags for that particular item in fact.

Anyway, hope you get your XML working. Getting used to the Flash security model always takes some learning, just like the forums ;)


 
Flag Post

I knew I’d seen it somewhere, but at the time it hadn’t been important (and hence not remembered), but I was unable to find it again when I did need it.
Meh, I still prefer BBCode.
Bah, especially when I want to use an asterisk to denote actions rather than bold. Oh well. Was reminded of a time when someone told me that phpBB was “the best free forum software there was” only to have me point them to four better ones (YabbSE being my personal favorite).

I want a preview button too.

 
Flag Post

I prefer the BBCode editor in Vbulletin as well. Textile is not hard for me but having an editor and preview is quite helpful.

 
Flag Post

Ah well, let us know if you solve the problem that sounds like a useful thing to know how to do!