A Flash Developer Resource Site

Results 1 to 1 of 1

Thread: Last updated:: May, 2008

  1. #1
    Senior Member
    Join Date
    Feb 2001
    Location
    Provo, Utah
    Posts
    1,112

    Please read this before posting.

    Aside from these pointers.. please look around for your answer before asking a question that might have already been answered.

    Where to start for Flash and XML
    - Tupps Flash/XML FAQ

    Where to start for XML in general
    - XML offers a method for describing data and it's relationship to other data.

    Adobe Provided Articles
    Loading, Parsing, and Locally Storing XML in Flash Lite 2
    XML Topic Center
    Integrating XML and Flash in a Web Application
    Tools: XML object
    XML and Macromedia/Adobe Flash from start to finish
    Connecting to Data in Flash Using Data Wizards

    - Also Check out:
    http://xml.com
    http://www.oreillynet.com/faqs/list.csp?id_subject=23
    http://www.oreillynet.com/pub/faqs/xml_faq_import
    http://www.oreillynet.com/pub/faqs/xml_faq_xmlsoft
    http://www.oreillynet.com/pub/faqs/xml_faq_terms

    How to post XML samples
    - Use 'PHP' brackets around your XML.

    Things you can not 'officially' do with just Flash
    (you need something else... php, asp, exe, rb, swfStudio, something...)
    - You can not save an XML file to a computer in anything other than a Shared Object.
    - You can not save an XML file to a server in anything other than a Shared Object

    Bringing Special characters in XML into Flash
    a 2008 thread by Kostas Zotos explains how

    Cut-n-Paste How to use a link in XML
    PHP Code:
    _root.createTextField("bob"1002525200200);
    _root.bob.html=true;
    _root.bob.htmlText=new XML("<top><![CDATA[ <a href='www.google.com'>Google</a>]]></top>").firstChild.childNodes[0].nodeValue
    Cut-n-Paste Using CDATA section to pass a parameter to a function
    PHP Code:
    _xml = new XML();
    _xml.ignoreWhite true;
    _xml.load("cdata.xml");

    _xml.onLoad = function(){
    showTxt.html true
    showTxt.htmlText this.firstChild.firstChild.nodeValue;
    };

    function 
    myFunc(param){
    trace(param);
    }; 
    cdata.xml
    PHP Code:
     <?xml version="1.0" encoding="UTF-8"?>
    <aNode>
    <![CDATA[<P ALIGN='CENTER'><B><FONT color='#FF0000'>
    <a href='asfunction:myFunc,rocket.jpg'>RED ROCKET</a>
    </FONT></B></P>]]>
    </aNode>
    Cut-n-Paste Parse nodes to array
    PHP Code:
    var _xml:XML = new XML();
    _xml.ignoreWhite true;
    _xml.load("pages.xml");

    var 
    arr:Array = new Array();
    var 
    num:Number 0;

    _xml.onLoad = function(){
    cNodes this.firstChild.childNodes;
    var 
    len:Number cNodes.length;
    for(var 
    n:Number=0;n!=len;n++){
    arr[n] = [];
    var 
    len2:Number cNodes[n].childNodes.length
    for(var 
    m:Number=0;m!=len2;m++){
    var 
    obj = new Object();
    obj.yr cNodes[n].attributes.yr;
    obj.txt cNodes[n].childNodes[m].firstChild.nodeValue;
    arr[n][m] = obj;
    }
    }
    showArr(num);
    };

    function 
    showArr(num){
    showTxt.text ""// showTxt - instance name of dynamic textfield
    showTxt.multiline true;
    showTxt.wordWrap true
    showTxt.html true;
    for(var 
    a:Number=0;a!=arr[num].length;a++){
    showTxt.htmlText += arr[num][a].txt
    }
    };

    nextPage_btn.onRelease = function(){
    num>=arr.length-num=num++;
    showArr(num);
    }; 
    pages.xml
    PHP Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <aNode>

    <cNodes0 yr="2006">
    <cNode>
    <![CDATA[<font size='15' color='#FF0000'><b>cNode0_0</b><br></font>Sep '06<br>txt 0<br><br>]]>
    </cNode>
    <cNode>
    <![CDATA[<font size='15' color='#0000FF'><b>cNode0_1</b><br></font>Aug '06<br>txt 1<br><br>]]>
    </cNode>
    <cNode>
    <![CDATA[<font size='15' color='#FF0000'><b>cNode0_2</b><br></font>Jun '06<br>txt 2<br><br>]]>
    </cNode>
    </cNodes0>

    <cNodes1 yr="2005">
    <cNode>
    <![CDATA[<font size='15' color='#FF0000'><b>cNode1_0</b><br></font>May '05<br>txt 0<br><br>]]>
    </cNode>
    <cNode>
    <![CDATA[<font size='15' color='#0000FF'><b>cNode1_1</b><br></font>Apr '05<br>txt 1<br><br>]]>
    </cNode>
    </cNodes1>

    <cNodes2 yr="2004">
    <cNode>
    <![CDATA[<font size='15' color='#FF0000'><b>cNode2_0</b><br></font>Mar '04<br>txt 0<br><br>]]>
    </cNode>
    <cNode>
    <![CDATA[<font size='15' color='#FF0000'><b>cNode2_1</b><br></font>Feb '04<br>txt 1<br><br>]]>
    </cNode>
    </cNodes2>

    </aNode>
    How to: XML based menu system

    Unfortunately I'm not familiar with other XML based menu systems, so I can't help you.

    I have, however, added a thread on the system I use.

    http://www.flashkit.com/board/showth...hreadid=416761

    Cut-n-Paste Method and Property code for the XML Object
    PHP Code:
    myXML = new XML("<top><inside/></top>");
        
    trace('new XML()');
        
    trace(myXML);
    trace('');
    myXML.firstChild.appendChild(new XML("<inside2/>"));
        
    trace('appendChild() using a String');
        
    trace(myXML);
    trace('');
    myXML.firstChild.appendChild(new XML(myXML.firstChild.firstChild));
        
    trace('appendChild() from an XML Object');
        
    trace(myXML);
    trace('');
    myXML.firstChild.appendChild(myXML.firstChild.childNodes[1].cloneNode(true));
        
    trace('cloneNode()');
        
    trace(myXML);
    trace('');
    newUnassignedElement=new XML().createElement("newElement");
        
    trace('createElement() from Global XML Object');
        
    trace(newUnassignedElement);
    trace('');
    myXML.firstChild.appendChild(newUnassignedElement);
        
    trace('append created element');
        
    trace(myXML);
    trace('');
    a_different_xml_object = new XML();
    newUnassignedElement=a_different_xml_object.createElement("newElement2");
        
    trace('createElement from an instance of the XML Object');
        
    trace(newUnassignedElement);
    trace('');
    myXML.firstChild.appendChild(newUnassignedElement);
        
    trace('append created element');
        
    trace(myXML);
    trace('');
    createdTextNode = new XML().createTextNode("this is the text");
        
    trace("Text node from createTextNode()");
        
    trace(createdTextNode);
    trace('');
    myXML.firstChild.firstChild.appendChild(createdTextnode);
        
    trace("append created text");
        
    trace(myXML);
    trace('');
    elementToGetAttributes=new XML().createElement("elementWithAttributes");
    elementToGetAttributes.attributes['type']="assigned attribute";
        
    trace("created element with assigned attribute");
        
    trace(elementToGetAttributes);
    trace('');
    myXML.firstChild.childNodes[2].appendChild(elementToGetAttributes);
        
    trace("appended element with assigned attribute");
        
    trace(myXML);
    trace('');
        
    trace("Test to see if root node has children: "+myXML.firstChild.hasChildNodes());
    trace('');
        
    trace("Test to see if Text node in root node's first child has children: "+myXML.firstChild.childNodes[0].firstChild.hasChildNodes());
    trace('');
    myXML.firstChild.insertBefore(new XML("<aNewNode>Here is some more text</aNewNode>"), myXML.firstChild.firstChild);
        
    trace("A new node inserted before the first child of the root node");
        
    trace(myXML);
    trace('');
    adXML = new XML("<root><something/></root>");
        
    trace("A new XML Object");
        
    trace(adXML);
    trace('');
    adXML.parseXML("<root><different/></root>");
        
    trace("adXML populated with different parsed XML information.");
        
    trace(adXML);
    trace('');
    adXML.firstChild.firstChild.removeNode();
        
    trace("Node removed from the middle of adXML");
        
    trace(adXML);
    trace('');
    stringVersion_of_adXML adXML.toString();
        
    trace("adXML type: "+typeof(stringVersion_of_adXML)); 
    Last edited by a_modified_dog; 05-31-2008 at 07:58 AM.
    Richard Lyman
    rich at lithinos.com
    www.lithinos.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center