[SOLVED] Using string to load a new world?


(Jacob Albano) #21

You can embed XML just like other assets.

[Embed(source = "path/to/file.xml", mimeType = "application/octet-stream")] private const MyXML:Class;

var xml:XML = FP.getXML(MyXML);

(Bora Kasap) #22

yeah but :confused: when i embed something like that, how can i change variables after compilation? i think i got something(complete wrong) wrong… thats not funny :frowning:

EDIT: Ahh, is that about that ā€œmimeTypeā€ thing? i see there is ā€œstreamā€ word there, is that means i didn’t get something wrong? :smiley:

EDIT AGAIN: reading xml only when compiling project :frowning:

FINAL EDIT: Why am i not using shared object to do something like that! :smiley:


(Jacob Albano) #23

ā€œOctet streamā€ means the file is in binary format. It’s a little strange but Flash requires it.

Shared Objects won’t help you here. As far as I know you can’t edit them manually and you don’t want your game data to be in that format.

If you want to change them after compilation you can use FLAKit. :heart: I didn’t realize that was what your most recent question was about.


(Bora Kasap) #24

yeap, you’re right again, shared object doesn’t help me, also i’ll use this stuff for importing xml files dynamically, so, i’ve just realized i can use URLLoader for this… i think this time it’ll work as i want… when i complete my levels, i’ll change URLloaders’ to ā€œFP.getXMLā€ā€¦

i’ve asked a little question at the beginning of this topic, but i’ve learnt lots of stuff because of talkflow… Even FLAKit not required to me, i’ll just control entities’ movement functions with this…


(Jacob Albano) #25

Yep, URLLoader is what you want. FLAKit is really just a way for me to avoid using event listeners when I load my data, since it loads everything ahead of time. It uses URLLoaders under the hood.


(Jacob Albano) #26

I feel like this thread already has enough in it, but I wanted to suggest an alternative to your switch statement.

var worlds:Dictionary = new Dictionary();
worlds["SECTOR_41"] = SECTOR_41;
// etc.

FP.world = new worlds[levelname]();

(Bora Kasap) #27

thanks again… class compiling problem solved completely :smiley: :smiley: :smiley: i’ve removed my all level classes from project file and i’m working on a template level class to load any xml level, so, i’m gonna publish my game with a level editor inside…


(Bora Kasap) #28

i’ve just used this dictionary stuff for something other, thats great!


(Ultima2876) #29