[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