Welcome, Guest
  • Author Topic: Dynamic Buttons fed by XML  (Read 9202 times)

    Ronald Wernecke

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 6203
      • View Profile
      • Professional Support
      • Email
    Dynamic Buttons fed by XML
    « on: 08/08/03, 08:01 »
    Hi cofighters ;)

    after there were so many requests for dynamic button creation, I put a small hint together for dynamic Button getting there Detaildata from XML.

    AS-Code ist this:
    [font=Verdana color=blue]
    function menuepoint(xmlData){
       this.label=xmlData.firstchild.attributes.label;
       this.page=xmlData.firstchild.attributes.page;
       this.xpos=xmlData.firstchild.attributes.x;
       this.ypos=xmlData.firstchild.attributes.y;
       this.level=xmlData.firstchild.attributes.level;
          attachMovie("menuepointMC",this.label,this.level);
          eval(this.label)._x=this.xpos;
          eval(this.label)._y=this.ypos;
          eval(this.label).label.text=this.label;
          eval(this.label).func.text=this.page;
          eval(this.label).onRelease=exec;
    }
    function exec(){
       getURL(this.page.text,"_mainFrame","POST");
    }
    [/font]

    you need to make a movieclip with the name menuepiont, havin a textbox named label and a hidden textbox named page.

    Thats more or less it.

    if you feed each instance of the button with a XML-Datastream, you can run a dynamic menue.

    Sample:

    menueXML="<menue label=\"HOME\" page=\"home.html\" x=\"10\" y=\"200\" level=\"10\"/>"
    l1=new XML(MenueXML);
    m1=new menuepoint(l1);

    In real life you would read the menueXML out of a XML data stream ;) and then you dont need these two extra steps preparing the XML data.

    Have fun with it


    happy flashing
    8)
    Ronald

    Flash-db

    • Administrator
    • Systems Administrator
    • *****
    • Posts: 1876
      • View Profile
      • Flash-db.com
    Re:Dynamic Buttons fed by XML
    « Reply #1 on: 08/15/03, 19:44 »
    Hey Ronald,

    Great post - You may want to move this to the Technical reference area - otherwise it may eventually become lost.

    Flash-DB

    `eniGM@dMiN“

    • Seasoned Programmer
    • ***
    • Posts: 136
      • View Profile
    Re:Dynamic Buttons fed by XML
    « Reply #2 on: 08/23/04, 04:39 »
    jus a small question, im doing this project for ma office, and im supposed to read XML data from a file into a flash movie.

    im not that experienced with XML (jus about kno how the code looks like)...

    in the top example, which part of the code is essential for the flash?
    (as i dont need to do any thin with XML, thats done for me)

    i simply need to know how i can read a specific value into the flash mc.


    thnx ppl!
    .
           __|_____
          |  o  o   /
          |  o  o |                  
    ,,=================================>
    ||.-----------------------------------,,------------““
      \|||||||> · eniGMa· · · · · · · · · · · · · · · · ·//
      =============================
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    Ronald Wernecke

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 6203
      • View Profile
      • Professional Support
      • Email
    Re:Dynamic Buttons fed by XML
    « Reply #3 on: 08/23/04, 13:06 »
    Hi,
    Flash does not car about headers and document declaration, but it needs "well formed XML tags".

    This means, you need one document tag around it (document beginning and ending with one tag pair)

    All Tags need to be closed.

    In the example there are only tags needed by flash for this purpose.

    You got to know, that working with attributes is faster, than with nodes.

    Thats about it. Basci know how of working with XML is enough. But you need a good understanding of what you are trying to do, and which data you are going to need.

    As with all data driven applications, you need to do some planing, if you use XML ;)
    happy flashing
    8)
    Ronald

    joejac

    • Guest
    Re:Dynamic Buttons fed by XML
    « Reply #4 on: 10/26/04, 17:52 »
    Hi Ronald, I can see that you are expert in this issue of Dynamic Buttons.

    I posted a couple of questions on "help with dynamic buttons in Flash & PHP/mySQL" following the link:

    http://www.flash-db.com/Board/index.php?board=4;action=display;threadid=10384;start=

    Would you wish to help me with those question in that post, since I have the data of text and links for the buttons in a mySQL table, thanks in advance. Please let me know If I need to post the questions again in this post.

    Alf

    Ronald Wernecke

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 6203
      • View Profile
      • Professional Support
      • Email
    Re:Dynamic Buttons fed by XML
    « Reply #5 on: 10/27/04, 12:00 »
    Hi Alf,
    look into my sample.
    It makes no difference, if you have a XML-stream or some other collection of data.
    XML makes it just a little easyer for this kind of application.
    In my sample, I use a fixed XML-Object, but you could write this with php and load it with xmlObject.load("scriptname"); as well.
    happy flashing
    8)
    Ronald