Author Topic: xml flexibility  (Read 1686 times)

Max

  • Newbie
  • *
  • Posts: 13
xml flexibility
« on: February 13, 2009, 12:27:02 pm »
For a project of mine i had to be able to dynamically add pages to an xml which got loaded by megazine. I ran intro a bit of an issue when i had to parse some or all data of that xml to one or more pages. We also have to add more data to the pages within the xml structure though it throws an error in the console it doesnt seem to matter much. Any thoughts on issues this might cause Florian?

Anyway, so i added the following to Image.as:
Code: [Select]
img["megazineSetup"](_mz, _page, _even, _library,_mz.xmlData);
img["megazineSetup"](_mz, _page, _even,_mz.xmlData);
img["megazineSetup"](_mz,_mz.xmlData);

This way the xmlobject gets passed to every page, which could be handy for if you want to just actionscript a custom index within 1 of your pages without using xml params. I thinks theres a lot room to increase flexibility on this part, it seems a bit to static to me. For non flashers i admit it workes very well and has loads of stuff to play with. But when you have to work with it within a project of your own or want to just simply adjust some basic settings it doesnt seem to be very easy, but maybe i just havent read the documentation very well :P

Florian Nücke

  • κρύα πόδια
  • Administrator
  • Hero Member
  • *****
  • Posts: 1989
  • MegaZine3 Developer
    • MegaZine3
Re: xml flexibility
« Reply #1 on: February 13, 2009, 03:20:45 pm »
Depends on where you add the tags in the xml. As you said "to the pages" I'm assuming inside the page tags. The engine interprets everything inside page tags as elements, so what would happen is the engine trying to load an external element with the name of the tag (i.e. an swf with the name, like the vid element). Most likely there is no such swf, therefore an error occurs. If it bothers you, have a look at the Element class, inside the load function. It first determines if it's an "internal element", i.e. one that can directly be instantiated, or an "external" one, i.e. one implemented inside an extra swf which has to be loaded. Before the

Code: [Select]
} else {
    // No, load the element swf file
    try {

part (around line 203) you could add an else if that catches all of your custom data tags (doing nothing at all, just avoiding the default case and thus the error).

As for the xml passing: well, yeah, for some cases that might indeed give a lot more freedom, I agree. Although I'm not very fond of your implementation - after all, if you have a getter in the MegaZine class, why not get the xml data via that getter in the swf itself, but instead pass it as an extra parameter? ;)
I'll add that getter in the next version.
For the Snark was a Boojum, you see.

Before you ask a question
          After you get an answer
  • please document your problem with the answer in the Project Wiki. (e.g. in the FAQs)
  • help others out if you can, by answering their questions on the forum.

Max

  • Newbie
  • *
  • Posts: 13
Re: xml flexibility
« Reply #2 on: February 13, 2009, 04:22:16 pm »
true about the xml getter part, havent really thought about it that way, that would be alot more sufficient indeed. Good point.