XML in AS3

Theres lots of functions to add child nodes, but is it right
that there are none to delete them. Is there a good approuch to
deleting just one node?

You use the delete operator to delete nodes from XML in AS3
http://livedocs.adobe.com/flex/201/langref/operators.html#delete_(XML)
"smazr123" <[email protected]> wrote in
message
news:f319oc$7nm$[email protected]..
> Theres lots of functions to add child nodes, but is it
right that there
> are none to delete them. Is there a good approuch to
deleting just one
> node?

Similar Messages

  • Loading XML in AS3

    OK, so I think I have the basics of loading XML in AS3. But I
    can't seem to access the info once it is loaded. I'm using the to
    load the .xml file:
    var myXML:XML = new XML();
    var XML_URL:String = "music.xml";
    var myXMLURL:URLRequest = new URLRequest(XML_URL);
    var myLoader:URLLoader = new URLLoader(myXMLURL);
    myLoader.addEventListener("complete", xmlLoaded);
    function xmlLoaded(event:Event):void
    myXML = XML(myLoader.data);
    trace("Data loaded.");
    But when I go to trace the .xml file with this:
    trace(myXML.toXMLString());
    I get nothing. However, if I place this trace inside the
    xmlLoaded function it traces it out. My problem is I want access to
    the info outside of that function. What am I doing wrong? Any
    advice or help would be greatly appreciated. Thanks.

    backpages,
    > But when I go to trace the .xml file with this:
    >
    > trace(myXML.toXMLString());
    >
    > I get nothing.
    This looks like a matter of timing. Your first five lines
    are
    encountered one after the other, starting with var myXML
    through
    myLoader.addEventListener(), which calls a function defined
    immediately
    below that. The function is called when the "complete" event
    is dispatched,
    which may take longer or shorter depending on the size of the
    XML document
    and network traffic. If you put a trace() statement
    immediately below that,
    Flash will execute that too -- and at the moment it does,
    your XML document
    hasn't loaded yet.
    > However, if I place this trace inside the xmlLoaded
    function it
    > traces it out. My problem is I want access to the info
    outside
    > of that function. What am I doing wrong?
    I copy/pasted your code exactly, then followed it with this:
    var t:Timer = new Timer(5000);
    t.addEventListener(
    TimerEvent.TIMER,
    function():void {
    trace(myXML);
    t.start();
    ... which waits five seconds, then runs that trace(). Sure
    enough, it
    outputs the XML contents.
    If you want to use the myXML variable elsewhere in your
    movie, you just
    have to make sure those other locations don't reference the
    variable until
    it has a value (or account for a lack of value in the logic
    they use). You
    might, for example, put a stop() action in frame one, along
    with the
    existing code (and instead of my timer), then have the
    "complete" event
    handler issue a play() action. In later frames, the myXML
    variable would
    have the data you need, because the playhead won't advance
    until the data
    have been loaded.
    David Stiller
    Co-author, Foundation Flash CS3 for Designers
    http://tinyurl.com/2k29mj
    "Luck is the residue of good design."

  • How to use motion xml in as3

    the following is the result of exporting motion preset to xml.
    <Motion duration="1" xmlns="fl.motion.*" xmlns:geom="flash.geom.*" xmlns:filters="flash.filters.*">
    <source>
      <Source frameRate="24" x="449.5" y="138.55" scaleX="1" scaleY="1" rotation="0" elementType="movie clip" instanceName="ball" symbolName="ball">
      <dimensions>
      <geom:Rectangle left="-51.5" top="-51.5" width="103" height="103"/>
      </dimensions>
      <transformationPoint>
      <geom:Point x="0.5" y="0.9956310679611651"/>
      </transformationPoint>
      </Source>
    </source>
    <Keyframe index="0"/>
    </Motion>
    can some one show me how the as3 script in flash should be in order to set the motion to my "ball" mc in the fla?

    use:
    var myXML:XML;
    var anim:Animator;
    var myLoader:URLLoader = new URLLoader();
    myLoader.load(new URLRequest("oman3d.xml"));
    myLoader.addEventListener(Event.COMPLETE, processXML);
    function processXML(e:Event):void {
    myXML = XML(e.target.data);
    animr=new Animator(myXML,ball);
    anim.play();

  • LineChart: reading xml in as3

    I'm trying to populate a lineChart with data in xml format. I
    don't know how to load the xml into the LineChart and LineSeries
    objects. I know that lineChart.series expects data in the form of
    an array, but do not know how to work around this.
    How can I get my xml to work?

    if you want to use the legacy(AS2) XML class for interpreting
    your XML, it has been renamed XMLDocument in AS3. so you could use:
    var myXML:XMLDocument=XMLDocument(myLoader.data);
    and continue to use your firstChild, childNodes etc.
    But if you want to try the AS3 methods for interpreting XML,
    called E4X, use the XML class. You'll find E4X much more intuitive
    and easier to use.
    The structure of XML hasn't changed at all, just the way
    Flash deals with it, so to answer your question, you do not need to
    rewrite your xml code to a different format.
    That said, however, you do need to look at your specific xml
    code as it isn't well formed. the last two tags are outside of the
    root tag. i've added indentation below to make this clear.
    The help is quite thorough on the new xml classes - read the
    section under Programming ActionScript 3.0, Working with XML, and
    if you've still got issues, feel free to post specific
    questions.

  • Slideshow from XML in AS3

    I'm WAY new to AS3 and I'm looking to create a slideshow
    driven by XML. Its a very simple XML file that can have 2 to 5
    images in it.
    I can get the images to load in, but am having problems on
    the Event.COMPLETE function I created. I can't seem to reference
    the target at all.. basically when the load is complete, I want to
    retrict it to a 600 width or 450 height (depending on whether its
    wider or taller).
    I can get that information, but have NO idea how to adjust
    the width and height of the target. I've tried event.target.name,
    and event.currentTarget.name, etc... I have no idea what to do
    next!!!
    I've attached all the code I have (just started it).
    Any help would be GREATLY appreciated!!!!!

    You can't manipulate the width and height of the actual
    content you're loading, you have to manipulate the object
    displaying this content. this can be either the loader's content
    DisplayObject or the loader itself.
    so where you say for example:
    info.width = 600;
    you should say
    loader.width = 600; //or loader.content.width = 600;

  • How to edit xml using AS3

    I want to edit xml file on run time dynamically using AS3
    Plzzzzzzzz if it possible send the tutorials links or sample script.

    Flash player 10 has support for accessing local system file. This can be done using the FileReference class. You can browse a loca file, rad it and then save it back. But at the time of saving, the user is prompted to choose a location for saving the file.
    Else you can use some server side technology with your app to read and write files.

  • Loading XML in AS3...trying to make a news reader

    Hello! I'm hoping someone can point me in the direction of a tutorial that shows how to create a "News Widget" from an XML file. I'm a designer so I know very little code...any help would really be appreciated!
    I would like to create a Flash file using AS3 that pulls info from three different nodes in an XML file. The pic below is a screen shot of what I'm trying to accomplish.
    Here's an example of my XML:
    <?xml version="1.0"?>
    <rss version="2.0">
    <channel><title>kstp.com - MORE NEWS</title>
    <item>
    <title>State announces details of Minnesota FluLine </title>
    <description><![CDATA[<img alt="" src="http://kstp.com/kstpImages/health_minnesota90.jpg" align="left" border="1" />The Minnesota Health Department will soon become the latest state to announce details of a toll-free nurse line for those... ]]></description>
    <link>http://kstp.com/news/stories/s1202318.shtml?cat=1</link>
    <subject/>
    <creator>kstp.com</creator>
    <pubDate>Wed, 21 Oct 2009 11:38:04 GMT</pubDate>
    </item>
    <item>
    <title>Environmental group to look at MN water pollution </title>
    <description><![CDATA[<img alt="" src="http://kstp.com/kstpImages/water_graphic.jpg" align="left" border="1" />An environmental group releases an analysis of industrial pollution in Minnesota's waters on Wednesday. <font size="2">Environment Minnesota says...</font>]]></description>
    <link>http://kstp.com/news/stories/s1202345.shtml?cat=1</link>
    <subject/>
    <creator>kstp.com</creator>
    <pubDate>Wed, 21 Oct 2009 10:13:46 GMT</pubDate>
    </item>
    </channel>
    </rss>
    For each row I would like to display the <title> info, <description> info and wrap all of that up in the <link> URL.
    I imaging there is a good tutorial out there but I don't know enough to search using the correct terms.
    Any help would be AWESOME!!
    Thank you!
    Melissa

    You're probably not going to find too much in the way of a tutorial that arranges the content exactly the way you want it laid out.  I'm not sure what you mean when you say you want an example of how to display more than one node's worth of information.  From what I remember that tutorial has several entries, each having a few pieces of information.
    Because some of your data appears to be html formatted, it may make it a little harder for you to control the layout.  You will probably have to go with some movieclip/textfield(s) combination in order to be able to format things the way you showed, possibly making use of the textfield's htmlText property.

  • Load , edit and update an external XML in AS3

    Hello to all of you!
    I'm new in Flash, so i would like some help here....
    I'm trying to build a User Interface (SWF) and provide it to my customers in order to have access (easely) and they can change the data (images & Texts) of an XML driven photo Gallery.
    I load the XML in Flash(CS4) i can 'trace' at the output panel the nodes but when i'm editing new data the changes are not "saved"...
    The Files look like this:
    gallery.xml
    fla
    <?xml version="1.0" encoding="utf-8"?>
    <objects>
       <picture_path>pictures/1.jpg</picture_path>
       <thumb_path>thumbs/1.jpg</thumb_path>
       <picture_desc> abcdefgabcdefg </picture_desc>
       <picture_title>  ABC  </picture_title>
       <picture_path>pictures/2.jpg</picture_path>
       <thumb_path>thumbs/2.jpg</thumb_path>
       <picture_desc> abcdefgabcdefg </picture_desc>
       <picture_title>   </picture_title>
       <picture_path>pictures/3.jpg</picture_path>
       <thumb_path>thumbs/3.jpg</thumb_path>
       <picture_desc>  abcdefgabcdefg  </picture_desc>
       <picture_title> ABCDEFG </picture_title>
    </objects>
    var captionsXMLLoader:URLLoader = new URLLoader();
    captionsXMLLoader.load(new URLRequest("gallery.xml"));
    captionsXMLLoader.addEventListener(Event.COMPLETE, captionsXMLLoadedHandler);
    function captionsXMLLoadedHandler(eventObj:Event):void {
           var captionsXML = new XML(eventObj.currentTarget.data);
           trace(captionsXML.picture_title[2]);                // -> ABCDEFG
      //  ( This line should change the data of XML ? )
           captionsXML.picture_title[2] = "Bla Bla Bla Bla...";
           trace(captionsXML.picture_title[2]);                // -> ABCDEFG
    Please some help here !!!

    Sorry Kglad, this isn't embedded straight in to a html fil but from a main swf (full screen flash website i'm building).
    The code example is a part of my nodes from the menu config xml...
    William

  • Convert XMLList to XML in AS3?

    Hello,
    I am trying to figure out how to convert an XMLList that I
    retreived from an XML instance back into well-formed XML in Flash
    CS3. Here is what I am doing.
    - I have an XML document loaded and I am displaying the
    contents in a datagrid component (which is working well).
    - I am then filtering the XML to obtain a subset of data by
    first obtaining an XMLList representing all elements of my XML
    instance and then filtering the list on a particular element (this
    is working well).
    - Now I want to display my filtered results in the datagrid
    and here lies the problem because the datagrid can't use an XMLList
    as a dataprovider. How do I convert this XMLList back into well
    formed XML so I can use it as my grid's dataprovider? I need to
    somehow get a root tag back on.
    Could I somehow use toXMLString() and then convert that to
    XML?
    Thank you in advance for any advice.
    TH

    I solved this so I thought I would post how I did it in case
    anyone would find this useful.
    1. First, convert your XMLList to an xml string:
    var yourXMLString:String = yourXMLList.toXMLString();
    2. Next, add a root tag to the beginning and end of your xml
    string.
    yourXMLString=
    "<your_root_tag>"+yourXMLString+"</your_root_tag>";
    3. Convert the string to xml.
    var yourNewXML:XML=new XML(yourXMLString);
    yourNewXML is now well-formed xml and will work as a
    dataprovider.
    TH

  • XML/AS3 Lightbox style gallery - need starting point....

    I've made a gallery slideshow before but wasn't as intuitive looking back at it now and I want to start fresh on this new project. I would like to convert a jQuery lightbox style gallery into a flash XML based AS3 image gallery with categories. I don't want to code the FLA, I want separate AS files.
    This is a school project for my website. I would use jQuery and I have more experience with it but this project needs a flash component. I'm just not sure where to start and looking for some advice on how and where I could find resources. I want it to be minimal as I can make it;
    - 8 thumbnails to a "page/section" with more flowed into page 2 or 3 etc. (or a srcoller)
    - a few buttons for categories
    - images fading in full size with a description when hovered over and a close button
    - preloader (simple bar)
    Esentially something like this > http://www.layeredpixels.com/tf/unibox/#works which is using http://razorjack.net/quicksand/ for the thumbnails. That might be ambitious but I'd suffice with a simple fade effect
    I just dont have much time and need to focus on other projects in the meantime so to find a good base with no fancy effects (yet) would really help. I've downloaded some galleries out there but most of the code is messy or outdated.
    http://www.republicofcode.com/tutorials/flash/as3gridgallery/8.php < this is alright, but all the code is done in the FLA. I might break it into AS files but it depends. And I would like help with adding categories to that.
    I want to look into implementing Greensock, so any pro's out there that can give any advice would help greatly

    The best way to get going is to choose a solution path and get started on it.  Then, to get help, come with specific coding problems to solve and not a shopping list of wants.

  • How to: Display Specific Xml Entry in AS3

    I have a very simple line of code that i'm trying to modify to display a specific entry in a xml file:
    AS3 Code:
    // The first step is to activate the XML object
    AmbientSettingsXML = new XML();
    With the XML Object now active you must now load an XML foramtted document.
    Any DTD or XLS formatting will be ignored.
    AmbientSettingsXML.onLoad = myLoad;
    AmbientSettingsXML.load("settings.xml");
    // Before proceeding to far into the program, make sure the XML document has loaded
    // Extract information from the XML file
    function myLoad(ok) {
    if (ok == true) {
    trace("ok");
    trace(AmbientSettingsXML);
    The Trace Displays:
    ok
    <?xml version="1.0"?>
    <settings>
    <appearance>
    <event_title>Streaming Demo 1</event_title>
    </appearance>
    </settings>
    So the question is, how do I display the "event_title" entry only? (String)
    Any help is appreciated,
    Thanks!

    var loader:URLLoader = new URLLoader();
    loader.addEventListener(Event.COMPLETE, completeHandler);
    var request:URLRequest = new URLRequest("yourxmlfile.xml");
    loader.load(request);
    function completeHandler(event:Event):void {
    var loader:URLLoader = URLLoader(event.target);
    var xml:XML = XML(loader.data);
    //xml.child("appearance")[0].child("event_title")[0];

  • AS3 and XML, HELP!

    Hi
    I have no idea where to post this, so pls forgive me if im in the wrong place, but I have an Assessment due tomorrow, I'm only 4 weeks knew to AS3 and Flash, and confused as, so pls forgive me if i also look silly asking this question.
    The issue is loading data from an XML file and having it present in a Flash website. Its a book review thing (i've altered the XML and AS3 for posting here so please bare that in mind), so the XML looks a little like this
    <books>
        <book>
            <bookName>The Monsters</bookName>
            <genres>
                <genre>Thriller</genre>
                <genre>Crime</genre>
                <genre>Comedy</genre>
            </genres>
            <description>about the mummies.</description>
            <image>mummies.jpg</image>
            <reviews>
                <review>
                    <date>16/07/2011</date>
                    <name>unnamed</name>
                    <info>
                        <rating>5</rating>
                        <why>blah blah</why>
                        <theGood>it was good...</theGood>
                        <the Bad>it was bad…</theBad>
                    </info>
                </review>
            </reviews>
        </book>
    <books>
    but each Book has multiple reviews, i've just shown you one. Anyway, i need to present this information in 3 dynamic text fields when a book is selected in my ComboBox… after a lot of trouble i got the basics of it. So in the Genre box the genres will display, and in the Description box the description will display, and in the Review box i can get all the information, but only with all the tags. I need it to display without any tags, it would be wonderful if i could figure out how i could put date, name etc in front of that information as well, but I cant even begin to figure that one out.  For the life of me i cannot figure it out. below is the code I have so far:
    //Load XML
    var booksXML:XML = new XML();
    var loader:URLLoader = new URLLoader();
    var request:URLRequest = new URLRequest("gigGuide.xml");
    loader.addEventListener(Event.COMPLETE,loaderOnComplete);
    loader.load(request);
    function loaderOnComplete(event:Event):void
       booksXML = new XML(event.target.data);
       var books:Array = new Array({label:"Select a Book"});
       for each (var book:XML in booksXML.band)
          books.push({label:book.bookName.toString(), data:book.description.toXMLString(),
                     infoLocal:book.genres.genre.toString(), infoDate:book.reviews.review.toString(),
                     infoImage:book.image});
       bandCB.dataProvider = new DataProvider(bands);
    //ComboBox changeable
    bookCB.addEventListener(Event.CHANGE, changeHandler2);
    function changeHandler2(event:Event):void
       genre_txt.text = ComboBox(event.target).selectedItem.infoLocal;
       description_txt.text = ComboBox(event.target).selectedItem.data;
       reviews_txt.text = ComboBox(event.target).selectedItem.infoDate;
       empty_mc.tex = ComboBox(event.target).selectedItem.infoImage; //doesn't work
    any help would be greatly appreciated, and the image doesn't work, i've already faced facts that im not going to get that one to work
    Thank you in advance

    From what I can see you have a few problems. In your loaderOnComplete you set the data provider with 'bands' but create a variable called 'books'.
    Also, you want to be using the XMLList object to parse your data out. It's much simpler.
    Have a look at the following:
    var booksXML:XML;
    function loaderOnComplete(e:Event):void
              booksXML = new XML(e.target.data);
              var books:XMLList = booksXML.book;
              trace(books[0].bookName);
              var bookReviews:XMLList = books[0].reviews.review;
              trace(bookReviews[0].name);
    trace(bookReviews[0].date);
    First we get all the book xml objects in an XML List - the trace traces book number 0's name - The Monsters.
    Next, you can get all the reviews for a book in another XML List. Here we use the first book - book[0] and trace out the review's name and date.
    You can iterate through an XMLList as it has a length() method - (not a length property)
    Also, loading an image for a book would be easy - you just grab the image property of the current book and then use a Loader to load it.
    trace(books[0].image);

  • AS3 XML reader

    I'm simply trying to read this XML with AS3.
    Here's my code.
    var myXML:XML;
    var myLoader:URLLoader = new URLLoader();
    myLoader.load(new URLRequest("
    http://www.windowgain.com/rss/redsoxrss.php"));
    myLoader.addEventListener(Event.COMPLETE, processXML);
    function processXML(e:Event):void {
    myXML = new XML(e.target.data);
    trace(myXML.
    ABCDEFGHIJKLMNOPQRSTUVXYZ );
    No matter what I put in that last line, I cannot get flash to
    output just an item's title in the XML. I can only get the output
    to trace the entire xml file.
    Please help?

    how do you know how his xml is setup? for example, i don't
    think that would work for:
    <videos>
    <video path='v_factory-tour.swf' fps='120'
    nosoundstart='true'/>
    <video path='v_iron-chefs.swf' fps='25'/>
    <video path='v_dry-aged-beef-timelapse.swf' fps='40'/>
    <video path='v_iron-chefs.flv'/>
    </videos>;

  • Convert AS2 to AS3 (XML / Slideshow)

    Hi everyone,
    I've created a slideshow in AS2 (with some help from a
    tutorial) but it is in AS2 unfortunately. I need it to be in AS3
    and I've tried to read some online tutorials and other online
    materials on AS3 and the difference, but I just seem to run my head
    against the wall every time.
    I don't know if it's a comprehensive task to ask but I take
    my chances and try anyway. Please let me know if this is way too
    much to convert / translate
    I've attached my AS2 code
    I short it has to load images from a XML file where a tag
    with caption (image title) and a tag with the delay settings.
    So far I’ve discovered that the XML loading in the very
    beginning is completely different in AS3 so I founded a tutorial on
    how to load XML data into flash. That is working alright but my
    next problem is to reset all the other variables (like caption,
    delay etc.) and I’ve read that XML in AS3 has a much faster
    and smarter way to load the tags. Now I just have to found out how
    that’s done :-)
    Thanks in advance
    eDevantie

    Are you using external .as files and classes or are you using frame scripts directly in the timeline? Are you used to any other object oriented programming languages? Knowing more about other languages you might know would help a lot.
    AS2 very informal and specialized to Flash. It relates to pretty much no other language out there, like JavaScript seldom relates. They're c-esque but only in a very distant 3rd cousin style.
    AS3 is much more OOP oriented and typed versus the less formal, error-prone loose dynamic nature of AS2. While your game would benefit greatly from the speed increases and error reduction, I think you're really swinging for the fence on this one. While some classes may resemble their AS2 counterpart and the core global functions work the same, everything else is different. Starting off trying to convert 4,000 lines of code is a little steep.
    As mentioned, the resources to learn AS3 are excessive and plentiful from video training to tutorials to the API reference itself. Google has it all.
    I think you really should lower your target and just try some really simple, basic things. Draw a shape, add a listener, do something basic when clicked, etc. You'll get a good idea of how different things are with the new display list rather than tearing your hair out converting your as2 game.

  • Date nodes in XML

    I'm working with XML in AS3. I'm loading in some xml that has dates in a format like:
    2011-1-12-10-00-a
    I am converting those to actual Flash Date so I can compare them and use the methods of the Date class, etc. I would prefer to convert them once and then store them back in the XML node they came from.
    Is it possible to store complex values like date or what have you in an XML?

    you can but not as a date object.  you have to serialize your date object, save that to your xml and then unserialize your date object.
    that may be less efficient than using a string to save to your xml and converting that back to ta date object.

Maybe you are looking for