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);

Similar Messages

  • Flash and XML help : (

    Hi all
    bit of a newbie, so probably quite easy if you know how:eek:
    would anyone beable to help with sorting out an XML file, what I have is a tooltip that loads in via XML and exported from flash. the XML loads in 2 text fields,  field and field2.
    what I am trying to do is add a button also to the tooltip so that you can click and go to a url.
    would anyone beable to help with this.
    this is what I have in my XML file;
    <?xml version="1.0" encoding="utf-8"?>
    <data>
        <image name="image 1" path="img/img1.jpg"
        title="Food Fight"
        text="Information here!" />
    </data>
    this loads in 2 text fields.
    this is what I have in my AS;
                  var tooltip:ToolTip = new ToolTip();
          //tooltip.buttonMode = false; 
                    tooltip.field.text = titles;//loads tooltip 1
                    tooltip.field2.text = texts;//loads tool tip 2
                    holder.addChild(tooltip);
    I thought I could do something like this but I seem to be getting errors
    XML
    <?xml version="1.0" encoding="utf-8"?>
    <data>
        <image name="image 1" path="img/img1.jpg"
        title="Food Fight"
        text="Information here!"
                 button="click to view/>
    </data>
    and in my AS
    var tooltip:ToolTip = new ToolTip();
                    //tooltip.buttonMode = false; 
                    tooltip.field.text = titles;//loads tooltip 1
                    tooltip.field2.text = texts;//loads tool tip 2
                    tooltip.field3.text = buttons;//loads tool tip 3
                    holder.addChild(tooltip);
    but just not working, what am I doing wrong:yikes:
    many thanks for any help!

    hi Saransoft
    thanks for that, thats great, yes it seesm to work I now have an extra text field with the menu that is the button, I have put my XML like this, is it correct
    <image name="image 2" path="img/img2.jpg"
      title="Jazz Time"
      text="Information"
      button="Click for URL"  />   //NEW THAT I ADDED FOR THE BUTTON IS THIS CORRECT?
    Now that I have another text for the button my final thing is getting it to be click able and go to a URL when you the text button is clicked. can I do this just in the XML file or is there also more to be added to the AS...aaaaaaaaaaaaarrrrrrrrghhhhh!!!!
    many thanks for your help??

  • AS2 and XML help please

    Hi, I found a previous post in this forum that does exactly
    what I would like to do, but since I am new to adobe flash I am
    missing some knowledge. I have the actionscript code and the xml
    file - what I need help with is the GUI. I open a new AS2 project
    and press F9 to insert the action code. What do I do next? Please
    help!
    I attach the previous actionscript code posted by another
    member.
    Best Regards Eva

    Hi, thanks for Your reply. Yes, I have the .xml file, what I
    need help with is the 'frame' that You display the picture in. Do I
    need to create a layer or scene? I guess that myContainer_mc in the
    code needs to be identified in this 'frame'. How do I go about
    doing this?
    Any help is most appriciated!
    Best Regards Eva

  • Java servlet, DOM and xml help! please urgent!

    I have to write a servlet that takes the user input to build a xml document using DOM API and should be able to append new entry to that xml file whenever any user adds an entry. I have written the fillowing code, can anyone please take a look at this code and tell me the right way to do it as this code is actually not creating any xml file and also in commented line of this code I tried by giving blank xml file name with just root element, so that this code can enter new elements like name, title as child element of the root, but doesn't work.
    PrintWriter out = res.getWriter ();
    res.setContentType ("text/html");
    try
    Document xmldoc = null;
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = factory.newDocumentBuilder();
    DOMImplementation impl = builder.getDOMImplementation();
    // Document xmldoc = builder.parse(xmlfile name);
    Element e = null;
    Node n = null;
    String name = req.getParameter("name");
    String title = req.getParameter("title");
    String address = req.getParameter("address");
    xmldoc = impl.createDocument(null, "records", null);
    Element root = xmldoc.getDocumentElement();
    e = xmldoc.createElementNS(null, "name");
    n = xmldoc.createTextNode(name);
    e.appendChild(n);
    root.appendChild(e);
    e = xmldoc.createElementNS(null, "title");
    n = xmldoc.createTextNode(title);
    e.appendChild(n);
    root.appendChild(e);
    e = xmldoc.createElementNS(null, "address");
    n = xmldoc.createTextNode(address);
    e.appendChild(n);
    root.appendChild(e);
    DOMSource domSource = new DOMSource(xmldoc);
    Source xslSource = new StreamSource (xsl file);
    TransformerFactory tf = TransformerFactory.newInstance();
    Transformer transformer = tf.newTransformer(xslSource);
    transformer.transform(domSource,new StreamResult (out));

    Document xmldoc = null;
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = factory.newDocumentBuilder();
    xmldoc = documentBuilder.newDocument();
    Element e = null;
    Node n = null;
    String name = req.getParameter("name");
    String title = req.getParameter("title");
    String address = req.getParameter("address");
    e = xmldoc.createElement("name");
    n = xmldoc.createTextNode(name);
    e.appendChild(n);
    xmldoc.appendChild(e);
    e = xmldoc.createElement("title");
    n = xmldoc.createTextNode(title);
    e.appendChild(n);
    xmldoc.appendChild(e);
    e = xmldoc.createElement("address");
    n = xmldoc.createTextNode(address);
    e.appendChild(n);
    xmldoc.appendChild(e);
    DOMSource domSource = new DOMSource(xmldoc);
    StreamSource xslSource = new StreamSource (xsl file);
    TransformerFactory tf = TransformerFactory.newInstance();
    Transformer transformer = tf.newTransformer(xslSource);
    transformer.transform(domSource,new StreamResult (out));

  • Help with ActionScript 2.0 and XML

    Here  I am trying  to use actionscript to load my content with is an XML file with html formatting. I have the actionscript on only 1 Scene  and i have links that switch between scences. The problem(s) is(are) that when I click the link  for the scene that has the actionscipt all it says is "null" where it should have the text i want to display from the XML file. Here is the code for the AS and XML:
    xml = new XML();
    xml.ignoreWhite = true;
    xml.load("contenido.xml");
    xml.onLoad = function () {
        txt = createTextField("txt",getNextHighestDepth(), 30, 300, 300, 100);
        txt.html = true;
        txt.htmlText = xml.firstChild.nodeValue;
    <?xml version="1.0" encoding="UTF-8"?>
    <htmlData><![CDATA[   Here is my <br/> html text   ]]></htmlData>
    any help is greatly appreciated

    Try...
    xml.onLoad = function () {
         txt = createTextField("txt",getNextHighestDepth(), 30, 300, 300, 100);
         txt.multiline = true;
         txt.html = true;
         txt.htmlText = xml.firstChild.childNodes[0].nodeValue;

  • I fouled up; erased library .itl and .xml files; need a little help

    I think I see what I did wrong (my issue relates to this reply post I submitted earlier today >> https://discussions.apple.com/message/16254985#16254985 but I don't think there's any need to go back and read that post to get the gist of my problem).
    So, after knocking around and reading a whole bunch of forum posts and Apple support pubs, I now know I did something dumb.
    Simply put, last night, in the course of attempting to delete from my MacBook Pro the iTunes library file residing there (the one designed to contain actual media files, i.e., music, books, podcasts, etc.), I also deleted the iTunes Library.itl and iTunes Library.xml files.  Yes, doh! is right.
    [BTW, the idea behind deleting the media library on the MBP was because my media files are -- and have been for some time -- located on an external hard drive.  So the good news is I still have all my media.  Of course, the bad news is I lost all playlists and a host of song-specific information and I'm sure a bunch of other stuff that is organized on the iTunes Library.itl file.  (Apple's helpful info sheet on the .itl and .xml files at >> http://support.apple.com/kb/HT1660)]
    So  I opened up iTunes today and there is nothing there, i.e., looks like just opened for the first time ever.  I now know that in the absence of the .itl and .xml files (which I trashed yesterday), iTunes went ahead and created new, empty versions of these files.
    HERE'S THE QUESTION: what should or can i do now to rebuild my library?  My media files still reside on my external HD and there they must stay because there isn't remotely enough room on the MBP hard drive itself.
    I'm just sort of stumped.  And skittish.  I don't want to make another dumb mistake that will make things even worse.  Any ideas?

    Hey, sorry to hear that, but good to know  that you have all your "stuff" and its just a matter of getting it all back together in the right place.  So, I have some ideas why it happened to me and maybe why this happened to you, which may be relevant later, but first I'll first explain how I got out of this jam.
    After much investigating, I finally did a search for .itl files and ended up "finding" one in the Media folder itself, specifically in the Music folder (yeah, should have done this much earlier).  Looking around, I also found the other files and folders that are supposed to be at same directory level as "iTunes Media." 
    At this point, I just moved them back to where they were supposed to be and opened iTunes and, voila, there was my stuff (albeit not quite all of it or exactly as it should be).  Then, after making sure my Media folder was properly identified in Advanced Preferences, I checked the boxes under File -> Library -> Organize Library and iTunes started doing some activity that seemed like it was reorganizing or rechecking the organization (you can see I am no expert here).
    So like I indicated, it wasn't exactly the way it was when I last used iTunes before I had the problems (e.g., various podcasts, books, etc. werent there -- so i just added them into the Library manually, i.e., File -> Add To Library, etc.).
    Anyway, I hope this helps if you haven't already fixed your problem.  If not, I might have some other ideas I came across while still searching for solution to my problem.  Best of luck.

  • HTML and XML files open in same window(KM Navigation iView)

    Hi All,
    I have created a KM navigation which is pointing the folder inside the documents repository. This folder contains HTML and XML files. It is rendering fine. But, when I click on the file links in KM Navigation iView, it is opening in new window.Here I need to open in same window. How can I acheive this?. Please help me.
    Thanks & Regards,
    Venkatesh R

    Hi ,
    check the below thread and try options mentioned in it
    https://www.sdn.sap.com/irj/sdn/thread?threadID=72594
    Koti Reddy

  • Problems with reports and XML-publisher - No XML

    Hi!
    I'm having a problem with Apps and XML-publisher. I made a report file, which queries some views. When executing in reports, I get all the data I expect.
    Now, when I upload the reportfile to Apps and let it generate XML, my xml-file is empty (well, almost empty)
    <?xml version="1.0" ?>
    <!-- Generated by Oracle Reports version 6.0.8.27.0 -->
    <T03501684>
    <LIST_G_PERSOON>
    <LIST_G_PERSOON />
    </T03501684>
    Anyone who can shed any light upon this problem?

    OK, finally solved the problem... A good night's sleep always helps ;).
    After just trying each queried table one after an other, I found the problem:
    The difference between Oracle Apps (Dutch locale) and the reports builder (English) is the language... And our functional people have changed some names, but the Dutch ones, leaving the english names in place and one of the tables I query has language specific data, which is also appears in a where clause.

  • Have itl and xml files on external hd am running home premium. can  no longer access files, am told this is because they were created with a newer version of itunes. also when i try to download 10.3 it wont, just says invalid drive j and for me to try aga

    i am running vista home premium on desktop and vista basic on laptop. have placed my itunes music with .itl and .xml files onto external drive connected to another desktop running vista and can no longer access music on first two mentioned comps only on the one connected to external drive. always am told that the library cant be read because it was created using a newer version of itunes. have tried to download 10.3 but it always tells me that i have and invalid hard drive j and to try again. any ideas?

    Older versions of iTunes cannot read libraries created with newer versions of iTunes. You need to have the same version of iTunes on all your PCs. Is that the case?
    As far as the problem installing iTunes goes, see this article from b noir on dealing with the problem:
    https://discussions.apple.com/thread/2450004
    If you get to the point where you need the Microsoft Installer cleanup utility, you will need more help as it has been withdrawn by Microsoft. but I am hoping the virtual drive trick will work,

  • How to disable 'Save' button when OAF and XML Publisher integrated...URGENT

    Hi,
    I am new to the OA Framework and XML publisher. I have been working on a requirement where I am designing a new page in Manager Self Service with few fields and a submit button. Also designed a RTF template in XML publisher to display the output in PDF format.
    When the details are entered on the page and click on 'Submit' button, the PDF will Open with the data populated. This is working perfectly... thanks to the forum.
    But my issue is: When the submit button is clicked, it displayes a dialog box with Open/Save/Cancel options and if I click the 'Open', the PDF will be opened. But my client is a retail client and they don't want store managers to save this PDF so either I have to skip this dialog box and directly open the PDF or I have to disable the 'Save' on the dialog box.
    Gurus -- Please help me how to achieve this. This is very urgent
    Below is the piece of code I am using in the controller to generate the PDF.
    TemplateHelper.processTemplate(
    ((OADBTransactionImpl)pageContext.getApplicationModule(webBean).getOADBTransaction()).getAppsContext(),
    APP_NAME,
    TEMPLATE_CODE,
    ((OADBTransactionImpl)pageContext.getApplicationModule(webBean).getOADBTransaction()).getUserLocale().getLanguage(),
    ((OADBTransactionImpl)pageContext.getApplicationModule(webBean).getOADBTransaction()).getUserLocale().getCountry(),
    inputStream,
    TemplateHelper.OUTPUT_TYPE_PDF,
    null,
    pdfFile);
    Thanks in Advance,
    Naren

    Frank, thanks for the update.
    But do you want me to try ControllerContext.getInstance().getCurrentViewPort().isDataDirty(); in button disable property?
    I have written one method in my am like
    public boolean isTransactionDirty(){
    return getDBTransaction.isDity();
    and exposed that method to client side and i try to use this method in my button disable property as
    disable#{bindings.isTransactionDirty.execute} but this is not working.
    Thanks

  • How to convert a Form to a Text file and XML file?

    Hi:
    I want to convert a Form to a Text file and XML file,but I don't know how convert?
    Please help!
    Oracle Form Builder V10.1.2.0.2
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0
    Thanks in advance!

    ..or follow the steps in Mtalink note; Doc ID: Note:196924.1
    Forms XML Conversion Feature ( Converting Forms To XML)

  • How to retreive images and xml stored in temporary internet files

    hi all,
                  I am creating an air application that has to work in offline too.so i have decided to retrieve datas it from temporary internet files(is it a rightway or anyother way to do that if so pls suggest).   I have an issues of retreiving images and xml stored in the temporary internet files of the user system ..can anybody help me and give solution for this..
    regards,
    Divya.

    What software are you using to create the website? Perhaps there is some command you can implement on the website to force the entire file to be downloaded. If you use Dreamweaver, you might ask in that forum. If you make the link an ftp link rather than a http link, you might guarantee that the file will be downloaded in its entirety, but the download location will not necessarily be in a temp folder.

  • Xml help with project?

    Hey guys, Java newbie here, was wondering if anyone could point me in the right direction.
    so my co-worker gave me a folder with a bunch of .tif image files and one .xml file. I'm supposed to write Java code to copy a folder with the same name as the folder he gave me, and copy the .xml file into that folder. so the end result is that we have the original folder w/ the .tif files and .xml file, and one copy folder with the same name with a copy of the .xml file in it.
    this is the code that i have so far:
    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    import org.w3c.dom.Node;
    import java.io.File;
    public class FileCopy{
    public static void copyFile(Document source, Document target)
    Node node = target.importNode(source.getDocumentElement(), true);
    target.getDocumentElement().appendChild(node);
    static void report(boolean b){
         System.out.println(b ? "success" : "failure");
    public static void main(String args[]){
         boolean status;
         status = new File("/project1").mkdirs();
         report(status);
    some of my questions are:
    A) how do i copy the exact name of the folder / .xml file?
    B) how do i even create a new blank .xml file for which i can use copyFile to copy over? (note it needs both a source and a target)
    C) how do i find the .xml file in the folder in which he gave me?
    Any help is appreciated

    rzhang10 wrote:
    Okay, but how do I ensure that the file I copied will be a .xml file?Mixing up of tenses leading to ambiguity! Bottom line: if it was XML, and you copy it, it will be XML.
    here is a copyFile function I found on the web:
    public static void copyFile(File in, File out) throws IOException{
              FileChannel inChannel = new FileInputStream(in).getChannel();
              FileChannel outChannel = new FileOutputStream(out).getChannel();
              try{
                   inChannel.transferTo(0 , inChannel.size(), outChannel);
              catch(IOException e){
                   throw e;
              finally{
                   if(inChannel != null) inChannel.close();
                   if(outChannel != null) outChannel.close();
    are you saying that this code would be sufficient to copy an .xml file? everytime I've tried it, it reproduces a .txt file.An XML file is a text file.

  • What is payload, xi-soap message and xml payload....

    can any 1 explains abt What is payload, xi-soap message and xml payload....

    Hi Shiva,
    see this abstract from messages file:
    "The SOAP header of a message contains all the important information that the Integration Server requires to forward the message, while the payload contains the actual business data (such as <PurchaseOrder> in the example above). <b>You can also append an unlimited number of attachments to the message before it is sent. Attachments typically comprise non-XML data, for example, pictures, text documents, or binary data."</b>
    Check this link for more info:
    http://help.sap.com/saphelp_nw04/helpdata/en/b6/0b733cb7d61952e10000000a11405a/content.htm
    Regards,
    Subhasha

  • How to connect ORACLE8i and xml

    this is sethu involving in the effort to do a project in xml and oracle 8i in the environment of weblogic.
    i need how to connect oracle8i using xml
    which enable me to start my project.
    with regards
    sethu
    email:[email protected]
    null

    I agree with the rest of you folks. JDOM will be your best bet for integration. I am currently using JDOM to parse and/or create xml documents. As mentioned the tutorials are very good to check out. If you just want to hit the JDOM highlights and hit the ground running check out this link. http://www.jdom.org/downloads/docs.html
    Take some time to check out the first 3 links on that page. They are JDOM and XML Parsing, Part 1, Part 2, and Part 3. Very good information about JDOM and XML parsing.
    Hope some of this will help!

Maybe you are looking for

  • Extended displays MacBookPro to Cinema Display

    I have a mid 2012 Mac Book Pro and a cinema display. Have the right connector between them but cannot get the CD display at its best high resolution - at BEST FOR DISPLAY it uses lo-res 1280x800 and same on SCALED. Help?

  • Closing front panel of subvi

    I have a main vi that opens many subvi with their front panel (they pop up as a normal windows not like modal). I need to close a subvi by pressing a button on it but I can't find any way. Thank you everyone, Massimo Ponte.

  • Flashplayer10 afcs.swc, components not shown in Design view

    Hi, When I use the FlashPlayer10 swc nothing is shown in the Design View. Is that bug ? isn't it just not working here ?

  • Saving a pdf file on an iphone

    iI'm trying to apply for jobs online. So when I need to give them my resume it's asking for it in a PDF file. I've downloaded apps that convert it into a PDF file but I cannot seem to save it anywhere but iBooks. I tried sending it to myself in an em

  • More than one PR in existing Material

    Hi Friends, Can u tell me if we can do n number of purchase requisition on the same material which created in material master.I tried but when it convert to quotation the same has not acceptable. Dont know were shud i mistaken this. Can anybody help