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

Similar Messages

  • JSP and Servlet - help please

    Hello,
    I am making this feedback for fun and a bit of learning too. I have an INDEX.JSP page, where the user selects the very first option. Depending upon the selected option he is moved another page PRODUCTFEEDBACK.JSP (so far I have completed this). Here as usual there are many fields to be filled in. As a spams protection i have done this;
    I have a AdditionClass, which is a seperate class where two number are generated at random. This numbers are called by PRODUCTFEEDBACK.JSP. The user is then asked to perform the addition. The completed form is then sent to ProductFeedback servlet.
    When I compile my PRODUCTFEEDBACK.JSP I get this error. Can you please tell whats wrong?
    PRODUCTFEEDBACK.JSP
          *<td>Please help us to prevent Spams by performing this simple mathematical Calculation. We appreciate your effort </td>*
        *</tr>*
      *</table>*
      *<jsp:useBean id = "AddTest" class = "go.AdditionClass" />*
      *<table width="53%"  border="0" align="center">*
        *<tr>*
          *<td><div align="center">*
      *<input name="textfield8" type="text" size="3" value ="<jsp:getProperty name="AddTest" property = "randNum1" />">*
    *  + * 
      *<input name="textfield9" type="text" size="3" value="<jsp:getProperty name="AddTest" property = "randNum2" />">*
    *  = *
    *<input name="_total" type="text" size="5">*
          </div></td>
        </tr>
        <tr>
          <td> </td>
        </tr>
      </table>
      <br>
      <table width="37%" height="23"  border="0" align="center">
        <tr>
          <td width="33%"> </td>
          <td width="67%"><input type="submit" name="Submit" value="Click here to send us this form"></td>
    AdditionalClass.java
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    package go;
    import java.util.Random;
    * @author MAC
    public class AdditionClass {
        Random generator = new Random();
        int randNum1; // First Random Number
        int randNum2; // Second Random Number
        public void SetNum1(){
            randNum1 = generator.nextInt(10); // Generate First Random Number
        public int getNum1(){
            return randNum1; //Return First Random Number
        public void SetNum2(){
            randNum2 = generator.nextInt(10); // Generate Second Random Number
        public int getNum2(){
            return randNum2; // Return Second Random Number
        // send the Random Numbers to ProductFeedback class
        public void productFeedbackRandNum1(){
            ProductFeedback productfeedback = new ProductFeedback();
            productfeedback.randomNumber1(randNum1);
        public void productFeedbackRandomNum2(){
            ProductFeedback productfeedback = new ProductFeedback();
            productfeedback.randomNumber2(randNum1);
    }Erros that I am getting:
    org.apache.jasper.JasperException: Cannot find any information on property 'randNum1' in a bean of type 'go.AdditionClass'
    C:\Documents and Settings\MAC\My Documents\NetBeansProjects\FeedBack\nbproject\build-impl.xml:462: The following error occurred while executing this line:
    C:\Documents and Settings\MAC\My Documents\NetBeansProjects\FeedBack\nbproject\build-impl.xml:440: Java returned: 1
    BUILD FAILED (total time: 1 second)

    Thank you for replying. I modified my Bean class then what is posted above, so thought to repost the code again and seek help. There seems to be no error now but it just dont generate any random numbers, All i get very time is 0. I am wondering, is my code generating 0 as random number, every time :-)
    package go;
    import java.util.Random;
    public class AdditionBean {
        int randNum1; // First Random Number
        int randNum2; // Second Random Number
        public void generateRandomNum1(){
            Random generator = new Random();
            int num1 = generator.nextInt(10);
            SetRandNum1(num1);
            // Send num1 value to ProductFeedback.java
            ProductFeedback productfeedback = new ProductFeedback();
            productfeedback.randomNumber1(num1);
        } // End of generaeRandomNum1
        public void generateRandomNum2(){
            Random generator = new Random();
            generator = new Random();
            int num2 = generator.nextInt(10);
            SetRandNum2(num2);
            // Send num1 value to ProductFeedback.java
            ProductFeedback productfeedback = new ProductFeedback();
            productfeedback.randomNumber2(num2);
        } // End of generateRandomNum2
        public void SetRandNum1(int num1){
            randNum1 = num1;
        public int getRandNum1(){
            return randNum1; //Return First Random Number
        public void SetRandNum2(int num2){
            randNum2 = num2;
        public int getRandNum2(){
            return randNum2; // Return Second Random Number
    }// End of classThank you,

  • After effects and photoshop ,,,help please

    hi all
    can anybody help please.
    ive been making a short film with my son and putting some basic effects in, just for a laugh.
    i noticed an effect on ADOBE TV that was done by Gareth Edwards in his movie MONSTERS which i thought would be good to try out in my film but i carnt get it right,,
    here is the link to that effect...            http://tv.adobe.com/watch/customer-stories-video-film-and-audio/monsters/
    its the effect where he changes the menu board in a cafe to one of his infected area signs, he allso changes a few other signs.
    in the video he say that he exports a still frame from after effects into photoshop and puts on his image {with a few tweaks her and there}, when hes got it ok in photoshop ,it some how updates in after effects??
    can any please help ,thank you

    It's a simplified explanation of the process.  He left out explanations of motion tracking and perspective matching that were most certainly required for the shot being discussed.
    If you are doing the same process to a static, locked off shot, with no foreground objects passing in front of your sign, it would be very possible to create a single frame in Photoshop and just layer it over your scene in AE.  But once the camera moves, you will need to understand Motion Tracking.  If objects pass in front of the replaced component, you will need to understand Masking.

  • Mail and password: Help please!!!

    I have changed my password and on my iPhone and iPad there is no problem. However, on my iMac, 10.8.2 every time I put the computer to sleep and then wake it up again Mail tells me to verify my password. I press OK but it refuses to accept and I am forced to go to System Preferences, then mail where I press OK for the same password and the whole thing then works.
    In Yahoo it works perfectly!
    What is happening in Mail. I have deleted the account in preferences and set it up again but all to no avail.
    Help please!!!

    You might try the following steps:
    Restart the device by holding down the on/off button until the power down slider appears.
    Try entering your password in another location (i.e. when you are using a different wifi network)
    Reset all settings (settings > general > reset), this resets some of your settings to factory default. It’s not a complete removal of settings. It removes all of your preferences for Wi-Fi, Bluetooth, Do No Disturb, Notifications, General, Sounds, Brightness & Wallpaper and Privacy. It does not remove any of your data.
    Try signing out of iCloud and back in (only if find my phone is disabled)
    If this doesn’t help your best option may be to contact Apple ID Support, upon speaking to an operator you should explain that your problem is related to your Apple ID, this way you will not be charged for assistance, even if you don’t have an AppleCare plan.

  • My iPod touch has no sound from music and videos help please

    My iPod touch has no sound at all, help please guys.

    - The restore from backup
    - If still problem restore to factory defaults/new iPod.
    - Last, make an appointment at the Genius Bar of an Apple store.

  • HT5622 After installing iTunes Match I have lots most of my iTunes songs and albums help please

    After installing iTunes Match I have lost most of my songs and albums help?

    iTunes Match on the computer will not change the library content.  The iTunes Match 3 step process must complete on the computer based library before being associated with any IOS devices.
    It is always important to make a secure backup of your Song files prior to these activities.

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

  • Java and XML . PLEASE help

    Hi,
    I am using a SAX Parser to create XML documnets on the fly
    I am creating an xml document with some elements
    <name> userName </name>
    <pwd> pwd </pwd>
    Is there any class which can be used to create tag names
    like CreateTag("name") and endTag();
    which will create <name> </name>

    wouldn't be hard to write a method to do that:
    public String createTag(String tag) {
      StringBuffer buffer = new StringBuffer();
      buffer.append("<").append(name).append(">");
      return buffer.toString();
    }

  • XML and E4x help please

    var xml:XML=<data>
    <nodes>
              <node>
                        <title>First title</title>
                        <category>good thing</category>
                        <category>fuzzy</category>
              </node>
              <node>
                        <title>Second title</title>
                        <category>sweet</category>
                        <category>good thing</category>
                        <category>organic</category>
              </node>
              <node>
                        <title>Third title</title>
                        <category>fuzzy</category>
                        <category>organic</category>
              </node>
    </nodes>
    </data>
    Let's say I have this XML. I want to get a list of the list nodes that contain a fuzzy category. I thought this would work:
         var myList:XMLList=xml.nodes.node.(category=="fuzzy");
    But that doesn't work. Because a given node might have multiple category nodes I thought I would need somethng like this:
         var myList:XMLList=xml.nodes.(node.(category=="fuzzy").length());
    But that didn't work either. Anybody know how to do this?

    Actually that does work....
    myList=xml.nodes.node.category.(text()=="fuzzy");
    for each(var a in myList){
              trace(a.parent().title);
    It seems there should be a way to combine that parent() bit into the expression....

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

  • Challenging issue for Java and XML Gurus.Please advise

    An extremely tricky and challenging code.
    I have been able to add 2 XML documents together
    using importNode().
    xmlDoc1
    <?xml version="1.0" encoding="UTF-8"?>
    <i:Interest xmlns:i="common">
    <i:Details xsi.type="i:vanilla.details.stock">
      <i:Strategy xsi.type="strategies:call">
         <strategies.Expiry>2009-12-01</strategies.Expiry>
      </i:Strategy>
    <i:Ref/>
    </i:Details>
    </i:Interest>
    xmlDoc2
    <?xml version="1.0" encoding="UTF-8"?>
    <i:Underlying value="KGF">
    <common:Currency>GBP</common:Currency>
    </i:Underlying>
    My Java Code to append them together
    NodeList list = xmlDoc2.getChildNodes();
    for (int i=0; i< list .getLength(); i++) {
         Element element = (Element)list.item(i);
         Node dup = xmlDoc1.importNode(element, true);
         xmlDoc1.getDocumentElement().appendChild(dup);
    Output:
    <?xml version="1.0" encoding="UTF-8"?>
    <i:Interest xmlns:i="common">
    <i:Details xsi.type="i:vanilla.details.stock">
         <strategies.Description>Call</strategies.Description>
         <strategies.Expiry>2009-12-01</strategies.Expiry>
       </i:Strategy>
    <i:Ref/>
    </i:Details>
    <i:Underlying value="KGF">
    <common:Currency>GBP</common:Currency>
    </i:Underlying>
    </i:Interest>     Query:
    I would like to add the 2nd XML Document after element <i:Ref> . How to do this? I dont want the 2nd XML doc after <i:details> but before it.
    Please help.

    Well. You say you want to insert a node as a child of another node, and it needs to be inserted before a certain other child node.
    There's an insertBefore() method in the Node interface. Use that.
    And if you thought that was a challenging issue then you might as well give up writing DOM code right now.

  • J6480 wireless and network help please!

    I have an officejet J6480 that has an error in printing system when printing wireless.  Everything is configured correctly and my printer reads the router and connects.  If this problem cannot be fixed, can i use an ethernet connection directly from printer to router and get it to work.  I tried this but also got a failure to print message.  Please help asap! Thank you

    hello,
    first, cancel the print jobs
    then try to restart the print spooler of the computer (click start>run... then type services.msc)
    look for print spooler in the list
    right click on the print spooler and click restart
    if that doesnt work, then do a partial reset on the printer
    unplug the power cord from the back of the printer without pressing the on button
    press and hold # and 3 and wait for 10 seconds
    plug the power cord back
    wait for the printer screen to lit up then release the # and 3
    try to ping the printer
    try to print a test page again
    keep me informed..

  • New to iCloud and need help please with getting it working

    I've got an iPad 2 and an iPhone 5 and have decided that it's about time to set up iCloud on my devices. I have followed the instructions on the website and in the icloud settings on both devices have switched on mail, contacts, calendars, reminders, safari, notes, photostream (my photo stream-on), documents and data, find my iphone, and icloud backup on. I have ensured that both devices have been backed up and automatic downloads on iTunes & App stores have all been switched on.
    I have not yet set up my PC for iCloud.
    My understanding is that icloud will sync new downloads and photos etc so I have just tried taking a picture on my iphone, expecting it to appear in my camera roll on my iPad and nothing has happened.
    Please can someone advise me if I am doing something wrong or how to resolve this.
    Many thanks.

    Welcome to the Apple Community.
    Photostream only syncs photos over Wi-Fi, make sure you are connected to Wi-Fi to begin with.
    Photostream only syncs when the camera app is closed, ensure it is closed.
    Photostream only syncs when the battery is above 20%, try recharging the device
    Try disabling photo stream on your device (settings > iCloud), restarting your device and then re-enabling photo stream.
    If this doesn't help you may need to reset photo stream. You can do this at icloud.com by clicking on your name in the top right corner and then the advanced settings in the pop-up dialogue box that appears.
    Note: disabling photostream and re-enabling it will result in any photos that are currently in the photostream album on your device, that are older than 30 days old, not being added back.

  • I'm new to java and need help please

    I have an assignment involves modifying a previous assignment. the code for the previous assigment is shown below.(it was required to be done as an applet this assigment can be an application or an applet) I'm trying to modify this code to read a text file (items.txt) that looks like this:
    item # description price(this line does not appear in the text file)
    001 shaving cream 400.00
    999 razors 30.00
    I need to load the item# and price from the text file into arrays(I have no clue how to use multi-dimensional arrays in java and would prefer not to)
    I need to search the arrays based on the values entered by the user (item # and quantity) calculate the total for that item then create a new text file which has each line item for that order in the form:
    item# quant price per item total(price per item*quant entered)
    also also I need to be able to display the four items listed above after each loop as well as all the previous item number and quantities they selected until they indicate they don't want to select anymore.
    I've been working on this for days and it seems like nothing I try works. My major problems are:
    1. I have no idea how to read the text file and load those 2 items into their respective arrays
    2. I can't seem to create a textfile that looks like text for the output file.
    code]
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.text.*;
    import java.util.Locale;
    public class arraySelection
    extends JApplet {
    //Initialize the applet
    private Container getContentPane=null;
    public void init() {
    String string_item, string_quantity;
    String output = "";
    String description= "";
    int counter= 0;
    int itemNumber= 0;
    double quantity = 0 ;
    double tax_rate=.07;
    double total= 0, price= 0;
    double tax, subtotal;
    double Pretotal= 0;
    double priceArray[] = {1, .5, 3.65, 0.02, 0.09};
    String descriptionArray[] = {"salt", "pepper", "paprika", "garlic", "thyme"};
    // create number format for currency in US dollar format
    NumberFormat moneyFormat = NumberFormat.getCurrencyInstance( Locale.US );
    //format to have the total with two digits precision
    DecimalFormat twoDigits = new DecimalFormat("0.00");
    //Jtextarea to display results
    JTextArea outputArea = new JTextArea ();
    // get applet's content pane
    Container container = getContentPane ();
    //attach output area to container
    container.add(outputArea);
    //set the first row of text for the output area
    output += "Invoice\nItem#\tDescription\tQuant@Price\t Line Total" + "\n";
    do //begin loop structure obtain input from user
    // obtain item number from user
    string_item = JOptionPane.showInputDialog(
    "Please enter an item number 1, 2, 3, 4, or 5:");
    //obtain quantity of each item that user enter
    string_quantity = JOptionPane.showInputDialog("Enter the quantity:");
    // convert numbers from type String to Integer or Double
    itemNumber = Integer.parseInt(string_item);
    quantity = Double.parseDouble(string_quantity);
    switch (itemNumber) {//Determine input from user to assign price and description
    case 10: // user input item =10
    price = priceArray[0];
    description = descriptionArray[0];
    break;
    case 20: // user input item =20
    price = priceArray [1];
    description = descriptionArray[1];
    break;
    case 30: //user input item =30
    price=priceArray[2];
    description = descriptionArray[2];
    break;
    case 40: //user input item =40
    price=priceArray[3];
    description = descriptionArray[3];
    break;
    case 50: //user input item =50
    price=priceArray[4];
    description = descriptionArray[4];
    break;
    default: // user input item is not on the list
    output += "Invalid value entered"+ "\n";
    price=0;
    description= "";
    //Calculates the total for each item number and stores it in subtotal
    subtotal = price * quantity;
    //display input from user
    output += itemNumber + "\t" + description + "\t\t"+ quantity + "@" +
    moneyFormat.format( price) + "\t" + moneyFormat.format( subtotal) + "\n";
    //accumulates the overall subtotal for all items
    Pretotal = Pretotal + subtotal;
    //verifies that the user wants to stop entering data
    string_item = JOptionPane.showInputDialog(" Enter a positive integer to continue or 0 to stop. ");
    itemNumber = Integer.parseInt(string_item);
    // loop termination condition if user's input is 0 .It will end the loop
    } while ( itemNumber!= 0);
    tax = Pretotal * tax_rate; // calculate tax amount
    total = Pretotal + tax; //calculate total = subtotal + tax
    //appends data regarding the subtotal, tax, and total to the output area
    output += "\n" + "Order Subtotal" + "\t" + moneyFormat.format( Pretotal) +
    "\n" + "Tax" + "\t\t" + twoDigits.format( tax ) + "\n" + "Order Total" +
    "\t\t" + moneyFormat.format( total );
    //attaches the data in the output variable to the output area
    outputArea.setText( output );
    } //end init
    }// end applet Invoice
    Any help or sugestions would be greatly appreaciated. I've been working on this for over a week and everything I try goes nowhere.

    item # description price(this
    line does not appear in the text file)
    001 shaving cream 400.00
    999 razors 30.00
    I need to load the item# and price from the text file
    into arrays(I have no clue how to use
    multi-dimensional arrays in java and would prefer not
    to)That's good, because you shouldn't use multidimensional arrays here. You should have a one-dimensional array (or java.util.List) of objects that encapsulate each line.
    I've been working on this for days and it seems like
    nothing I try works. My major problems are:
    1. I have no idea how to read the text file and load
    those 2 items into their respective arrays
    2. I can't seem to create a textfile that looks like
    text for the output file.The java.io package has file reading/writing classes.
    Here's a tutorial:
    http://java.sun.com/docs/books/tutorial/essential/io/index.html

  • I'm new to java and need help please(repost)

    I have an assignment involves modifying a previous assignment. the code for the previous assigment is shown below.(it was required to be done as an applet this assigment can be an application or an applet) I'm trying to modify this code to read a text file (items.txt) that looks like this:
    item # description price(this line does not appear in the text file)
    001 shaving cream 400.00
    999 razors 30.00
    I need to load the item# and price from the text file into arrays(I have no clue how to use multi-dimensional arrays in java and would prefer not to)
    I need to search the arrays based on the values entered by the user (item # and quantity) calculate the total for that item then create a new text file which has each line item for that order in the form:
    item# quant price per item total(price per item*quant entered)
    also also I need to be able to display the four items listed above after each loop as well as all the previous item number and quantities they selected until they indicate they don't want to select anymore.
    I've been working on this for days and it seems like nothing I try works. My major problems are:
    1. I have no idea how to read the text file and load those 2 items into their respective arrays
    2. I can't seem to create a textfile that looks like text for the output file.
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.text.*;
    import java.util.Locale;
    public class arraySelection
        extends JApplet {
      //Initialize the applet
      private Container getContentPane=null;
      public void init() {
           String string_item, string_quantity;
           String output = "";
           String description= "";
           int counter= 0;
           int itemNumber= 0;
           double quantity = 0 ;
           double tax_rate=.07;
           double total= 0, price= 0;
           double tax, subtotal;
           double Pretotal= 0;
           double priceArray[] = {1, .5, 3.65, 0.02, 0.09};
           String descriptionArray[] = {"salt", "pepper", "paprika", "garlic", "thyme"};
         // create number format for currency in US dollar format
         NumberFormat moneyFormat = NumberFormat.getCurrencyInstance( Locale.US );
         //format to have the total with two digits precision
         DecimalFormat twoDigits = new DecimalFormat("0.00");
         //Jtextarea to display results
         JTextArea outputArea = new JTextArea ();
         // get applet's content pane
          Container container = getContentPane ();
          //attach output area to container
          container.add(outputArea);
         //set the first row of text for the output area
        output +=  "Invoice\nItem#\tDescription\tQuant@Price\t Line Total" + "\n";
        do //begin loop structure obtain input from user
               // obtain item number from user
               string_item = JOptionPane.showInputDialog(
                   "Please enter an item number 1, 2, 3, 4, or 5:");
               //obtain quantity of each item that user enter
               string_quantity = JOptionPane.showInputDialog("Enter the quantity:");
               // convert numbers from type String to Integer or Double
               itemNumber = Integer.parseInt(string_item);
               quantity = Double.parseDouble(string_quantity);
                 switch (itemNumber) {//Determine input from user to assign price and description
                    case 10: // user input item =10
                      price = priceArray[0];
                      description = descriptionArray[0];
                      break;
                    case 20: // user input item =20
                      price = priceArray [1];
                      description = descriptionArray[1];
                      break;
                    case 30: //user input item =30
                      price=priceArray[2];
                      description = descriptionArray[2];
                      break;
                    case 40: //user input item =40
                      price=priceArray[3];
                      description = descriptionArray[3];
                      break;
                    case 50: //user input item =50
                      price=priceArray[4];
                      description = descriptionArray[4];
                      break;
                    default: // user input item is not on the list
                    output += "Invalid value entered"+ "\n";
                    price=0;
                    description= "";
             //Calculates the total for each item number and stores it in subtotal
             subtotal = price * quantity;
             //display input from user
             output += itemNumber + "\t" + description + "\t\t"+ quantity + "@" +
                       moneyFormat.format( price) + "\t" + moneyFormat.format( subtotal) + "\n";
             //accumulates the overall subtotal for all items
             Pretotal = Pretotal + subtotal;
            //verifies that the user wants to stop entering data
            string_item = JOptionPane.showInputDialog(" Enter a positive integer to continue or 0 to stop. ");
            itemNumber = Integer.parseInt(string_item);
          // loop termination condition if user's input is 0 .It will end the loop
       } while ( itemNumber!= 0);
        tax = Pretotal * tax_rate; // calculate tax amount
        total = Pretotal + tax; //calculate total = subtotal + tax
        //appends data regarding the subtotal, tax, and total to the output area
        output += "\n" + "Order Subtotal" + "\t" + moneyFormat.format( Pretotal) +
                  "\n" + "Tax" + "\t\t" + twoDigits.format( tax ) + "\n" + "Order Total" +
                  "\t\t" + moneyFormat.format( total );
         //attaches the data in the output variable to the output area
         outputArea.setText( output );
      } //end init
    }// end applet InvoiceAny help or sugestions would be greatly appreaciated. I've been working on this for over a week and everything I try goes nowhere.

    First answer: You shouldn't ask multiple questions in the same thread. Ask a specific question, with an appropriate subject line (optionally, assign the number of Dukes you are willing to give for the help). When question #1 is answered and question #2 arises, it's time for a new thread (don't forget to give out Dukes before moving on).
    Second answer: I think you need a Transfer Object (http://java.sun.com/blueprints/patterns/TransferObject.html). It's whole purpose is to hold/transfer instance data where it is needed. Create a class something like this:
    public class ItemTO
        private String _number;
        private String _description;
        private double _price;
        public ItemTO( String number, String description, double price )
            _number = number;
            _description = description;
            _price = price
        // Getter/Setter methods go here
    }then, in the code where you read in the file do something like this:
    BufferedReader input = null;
    try
        input  = new BufferedReader( new FileReader( "c:\\a.txt" ) );
        List items = new ArrayList();
        String line;
        String itemNumber;
        String itemDescription;
        double itemPrice;
        while ( (line  = input.readLine() ) != null )
         System.out.println( line );
            itemNumber = // Parse it from line
            itemDescription // Parse it from line
            itemPrice = // Parse it from line
            items.add( new ItemTO( itemNumber, itemDescription, itemPrice ) );
    catch ( FileNotFoundException fnfe )
        fnfe.printStackTrace();
    catch ( IOException ioe )
        ioe.printStackTrace();
    finally
        try
            if ( input != null )
                input.close();
        catch ( Exception e )
            e.printStackTrace();
    }As for how to parse the line of the file, I'll leave that to you for now. Are the three values delimited with any special characters?
    jbisotti

Maybe you are looking for