Need help with code not displaying on the Stage:(

// The following code is for a puzzle i'm trying to create, but it doesn't seem to want to display:
stop();
          import flash.display.stage;
    import flash.events.stage;
    import flash.text.stage;
    import flash.utils.stage;
var solve_btn:SimpleButton;
var myFormat:TextFormat;
var theSolution:Array;
var visualGrid:Array;
var showSolutionTimer:Timer;
var s:Sudoku;
var iGridUnsolved:Array;
var showSolutionStepsOrder:Array;
        function Solution()
            addFrameScript(0,frame1);
            return;
        }// end function
function randomSort(param1, param2:Object) : int
            return 1 - Math.floor(Math.random() * 3);
        }// end function
        function createGrid() : void
            var location_2:TextField = null;
            var location_1:int = 0;
            while (location_1 < 81)
                location_2 = new TextField();
                location_2.x = Math.floor(location_1 / 9) * 67 + 108;
                location_2.y = location_1 % 9 * 57 + 48 + 20;
                location_2.width = 60;
                location_2.height = 53;
                location_2.defaultTextFormat = myFormat;
                if (iGridUnsolved[location_1] != 0)
                    location_2.text = iGridUnsolved[location_1];
                visualGrid.push(location_2);
                this.addChild(location_2);
                showSolutionStepsOrder.push(location_1);
                location_1++;
            showSolutionStepsOrder.sort(randomSort);
                              return;
        }// end function
        function frame1()
            s = new Sudoku();
            iGridUnsolved = new Array(3, 5, 0, 4, 6, 0, 2, 0, 0, 6, 0, 0, 1, 0, 2, 0, 4, 0, 0, 1, 0, 3, 0, 0, 0, 7, 8, 0, 0, 4, 0, 1, 8, 5, 0, 7, 0, 6, 5, 0, 0, 0, 9, 8, 0, 0, 0, 7, 6, 5, 0, 1, 0, 0, 7, 8, 0, 0, 0, 6, 0, 2, 0, 0, 2, 0, 8, 0, 9, 0, 0, 3, 0, 0, 0, 0, 7, 1, 0, 5, 6);
            visualGrid = new Array();
            myFormat = new TextFormat();
            myFormat.color = 000000;
            myFormat.font = "Arial";
            myFormat.size = 24;
            myFormat.align = TextFormatAlign.CENTER;
            showSolutionStepsOrder = new Array();
            createGrid();
            theSolution = s.solve(iGridUnsolved);
            showSolutionTimer = new Timer(90);
            showSolutionTimer.start();
            showSolutionTimer.addEventListener(TimerEvent.TIMER, showStep);
                              solve_btn.addEventListener(MouseEvent.CLICK, Start);
            return;
        }// end function
        function showStep(event:TimerEvent) : void
            var location_2:* = showSolutionStepsOrder.pop();
            var location_3:* = theSolution[location_2];
            var location_4:* = new TextFormat();
            new TextFormat().color = 0;
            if (visualGrid[location_2].text.length == 0)
                visualGrid[location_2].text = location_3;
                visualGrid[location_2].setTextFormat(location_4);
            if (showSolutionStepsOrder.length == 0)
                showSolutionTimer.stop();
            event.updateAfterEvent();
            return;
        }// end function
// Its probably something really small, just can't figure it out myself.

Not sure why you are using addFrameScript() - try just calling the funcion, i.e. replace this
function Solution()
    addFrameScript(0,frame1);
    return;
}// end function
with this
frame1();
Kenneth Kawamoto
http://www.materiaprima.co.uk/

Similar Messages

  • Need help for style not displaying correctly in chm

    I’m using RoboHelp HTML version 8.  RH8 is dropping a style from my stylesheet.  The style appears to be applied correctly when I view a topic (the HTML file) directly with either IE or Firefox browser, and it appears correctly when I view the topic with the “Item View” feature in RH8 (the eyeglasses icon).  However, in the compiled HTML help output from RH, the style is not correct.  The style in question is a class of style (“desc” for descriptions) for a subset of table data. The “desc” class should have the data in the cell left justified, and the cell width should be 50%.  The main parent style for table data (centered text, cell width varies) seems to be applied instead, and the child style for descriptions is not applied.  Below I've included a screen shot of a table page as it looks in Item Viewer, then the same page as it appears in the CHM, and finally the style sheet in its original state before being added to RH.
    Here are things I’ve checked for:
    ·         The project is large, with over 6300 topics and a compiled chm of 5560 KB.  RH crashes when I try to apply style sheets or master pages to multiple topics from the Topic List.  However, I created a much smaller test project with 122 topics and still get the dropped style.
    ·         The style sheets were created outside of RH, and are also used for presenting the same content over the web outside of RH.  The styles display fine in the other context through a browser.  I have not modified the style sheet in RH, but I have opened it in RH.  I’ve also tried deleting and re-copying the style sheet into the project.
    ·         There is another set of styles applying to the tables, for table rows.  There is a “tr” class for the heading and classes for rotating background colors.  These child styles appear correct with no problems.  Every row in a table belongs to a child class of row styles.  In the case of table data styles, most cells require the parent “td” style and only a subclass require the child “desc” style.  It’s the “desc” style that isn’t showing up in the chm.  Is this a clue?
    ·         Multiple style sheets per topic.  Apparently only one style sheet can be used per topic.  In my project, I have two types of topics, called schema pages and table pages, with a style sheet for each.  The same master page is used for both types.  The master page uses the tables style sheet.  Therefore, the tables topics (the ones with the dropped style) use only one style sheet, but it is specified in both the master page and the topic itself.   Is this a problem?
    ·         Reviewing the style sheet in RH.  When I inspect the style sheet through RH’s Project Manager, the table data and table row styles appear under “Other” and not under “Table.”  Is this a clue?
    The special formatting of the description cells in our table-heavy project is essential.  I’ve spend days trying to troubleshoot this problem and would appreciate any help anyone can offer.

    Hi jensei,
    Thanks for that. When I took that screenshot - bizarrely those cells all had exactly the same html. I can't easily prove that now as I have tinkered with that test page quite a lot since. I started thinking maybe I could do something "clever" with table styles to save me the joyless task of manually editing all tables in my project. In the end I gave up and decided to devote a couple of hours to going through and reformatting all tables with a font that was the same size and of a similar type face to the rest of the page. Obviously not an option in your monster project, but it worked for me.
    I've seen so many random results here that I can't get my head around what exactly is going wrong - for me the issue seems connected with style = none in a table.
    Anywhere else on the page, style = none yields text with font = Tahoma 10pt.
    But in the table cells that text sometimes rendered ok in CHM, but often it would randomly appear far larger.
    So for me the cure was to format all tables with font = arial 10pt (rendered result is similar, but somehow different enough to stop the erroneous size rendering).
    That's as far as I got - as usual with time being very precious, I've had to curb my geekiness and crack on.
    Cheers,
    Andy

  • I need Help with codes. It isn't working

    I had once writing a code for finding the factorial of a number in elementary programming with C. I tried to incorporate it into my work. However, it is not working.
    Below are the major hitches:
    1. I have a problem with entering two numbers by simply pressing the buttons. Once i try to input another number the second number displaces the first on the textfield. Which suffices to say that entering a two or three digit number via the buttons is not working.
    2. What I intend to archieve is such once I have enter the numbers using the buttons i could get the factorial of whatever number i entered by simply pressing the n! button. Once i attempt pressing the n! button it displays error in the command prompt (a long list of error comments).
    How should I Proceed.
    Below is my full code:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class PanFrame extends JFrame implements ActionListener
         JTextField jTfd =new JTextField(20);
         JButton jbtn7 = new JButton ("7");
         JButton jbtn8 = new JButton ("8");
         JButton jbtn9 = new JButton ("9");
         JButton jbtn4 = new JButton ("4");
         JButton jbtn5 = new JButton ("5");
         JButton jbtn6 = new JButton ("6");
         JButton jbtn1= new JButton ("1");
         JButton jbtn2 = new JButton ("2");
         JButton jbtn3 = new JButton ("3");
         JButton jbtn0 = new JButton ("0");
         JButton jbtnFT = new JButton ("n!");
         public PanFrame (String title)
                   super (title);
                   Panel pan1 = new Panel();
                   getContentPane().setLayout(new FlowLayout ());
                   pan1.add(jTfd);
                   Panel pan2 = new Panel();
                   getContentPane().setLayout (new GridLayout (4,5,2,2));
                   pan2.add (jbtn7);
                   pan2.add (jbtn8);
                   pan2.add (jbtn9);
                   pan2.add (jbtn4);
                   pan2.add (jbtn5);
                   pan2.add (jbtn6);
                   pan2.add (jbtn1);
                   pan2.add (jbtn2);
                   pan2.add (jbtn3);
                   pan2.add (jbtn0);
                   pan2.add (jbtnFT);
                   getContentPane().add(pan1);
                   getContentPane().add(pan2);
                   //adding the Listener     
                   jTfd.addActionListener(this);
                           jbtn7.addActionListener(this);
                   jbtn8.addActionListener(this);
                   jbtn9.addActionListener(this);
                   jbtn4.addActionListener(this);
                   jbtn5.addActionListener(this);
                   jbtn6.addActionListener(this);
                   jbtn1.addActionListener(this);
                   jbtn2.addActionListener(this);
                   jbtn3.addActionListener(this);
                   jbtn0.addActionListener(this);
                   jbtnFT.addActionListener(this);
                   validate();
                   this.addWindowListener (new WindowAdapter()
                        public void windowClosing (WindowEvent we)
                                  setVisible (false);
                                  System.exit (0);
               public void actionPerformed(ActionEvent ae)
                        jTfd.setText(ae.getActionCommand());
                   if(ae.getActionCommand()=="n!")
                                  int num= Integer.parseInt(jTfd.getText());
                             int i;
                             long fact=1;
                             for(i=1; i<=num; i++)
                                       fact *=i;
                             jTfd.setText(String.valueOf(fact));
         public static void main (String arg [ ])
                   PanFrame ObjFr = new PanFrame ("Two Panel in One Frame");
                   ObjFr.setSize (400, 400);
                   ObjFr.setVisible (true);
    }bakes

    Perhaps something like this?
    private String tempText = "";
    public void actionPerformed(ActionEvent ae) {
    if (jTfd.replaceSelection( jbtn.getActionCommand()
    ) )=="n!") {
              tempText = "";
              long fact=1;
    for(int i=1; i<=Integer.parseInt(jTfd.getText());
    ); i++)
                   fact *=i;
              jTfd.setText(String.valueOf(fact));
         else {
    tempText +=
    += ((JButton)ae.getSource()).getActionCommand();
              jTfd.replaceSelection(tempText);
               * // Alternately, you can try:
    * jTfd.setText(jTfd.getText() +
    ) + ((JButton)ae.getSource()).getActionCommand());
         }}I tried out what you suggested above but it gave the following eror:
    PanFrame.java103:cannot resolve symbol
    symbol: variable jbtn
    location: class PanFrame
    if (jTfd.replaceSelection( jbtn.getActionCommand() )=="n!")
    'void' type not allowed here
    if (jTfd.replaceSelection( jbtn.getActionCommand() )=="n!")
    I do not think "if(jTfd.replaceSelection(jbtn.getActionCommand())=="n!")"
    is the correct way of expressing what i intend to archieve. When i first wrote it out it did not make sense to me but i could not find an alternative. so i said let me give it a triy.
    i have also attempted to structure it this way
    public void actionPerformed(ActionEvent ae)
                   JButton jbtn = (JButton)ae.getSource();
                   jTfd.replaceSelection( jbtn.getActionCommand() );
                   if (ae.getSource()==jbtnFT)
                        int num= Integer.parseInt(jTfd.getText());
                             int i;
                             long fact=1;
                             for(i=1; i<=num; i++)
                                       fact *=i;
                             jTfd.setText(String.valueOf(fact));
              } the action i performed having structured it as stated above was: I pressed the button 5 and it displayed 5 in the textfield then i wanted to find the factorial of 5. so i pressed the (n!) button. instead of calculating the factorial of 5 and displaying the output in the textfield, the factorial symbol was displayed after the number 5 and error messages were displayed in the command prompt. i have tried to type out some of the messages below:
    java.lang.NumberFormatException: For input string: "5n!" at java.lang.NumberFormat Exception.forInputString(NumberFormatException.java.48)
    at java.lang.Integer.parseInt(Integer.java: 477)
    at java.lang.Integer.parseInt(Integer.jaa:518)
    at PanFrame.actionPerformed(Drum.java:107)
    at javax.swing.AbstractButton.fireActionPerformed (AbstractButton.java:1786)
    at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1839)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
    Please could you do me favor i am posting the entire code below: copy it and run it then you can see the error messages in its entirety. It is quite lenghty was i tried to type out were jus the first few lines.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class PanFrame extends JFrame implements ActionListener
         JTextField jTfd =new JTextField(20);
         JButton jbtn7 = new JButton ("7");
         JButton jbtn8 = new JButton ("8");
         JButton jbtn9 = new JButton ("9");
         JButton jbtnFT = new JButton ("n!");
         JButton jbtn4 = new JButton ("4");
         JButton jbtn5 = new JButton ("5");
         JButton jbtn6 = new JButton ("6");
         JButton jbtn1= new JButton ("1");
         JButton jbtn2 = new JButton ("2");
         JButton jbtn3 = new JButton ("3");
         JButton jbtn0 = new JButton ("0");
         public PanFrame (String title)
                   super (title);
                   Panel pan1 = new Panel();
                   getContentPane().setLayout(new FlowLayout ());
                   pan1.add(jTfd);
                   Panel pan2 = new Panel();
                   getContentPane().setLayout (new GridLayout (4,5,2,2));
                   pan2.add (jbtn7);
                   pan2.add (jbtn8);
                   pan2.add (jbtn9);
                   pan2.add (jbtnFT);
                   pan2.add (jbtn4);
                   pan2.add (jbtn5);
                   pan2.add (jbtn6);
                   pan2.add (jbtn1);
                   pan2.add (jbtn2);
                   pan2.add (jbtn0);
                   getContentPane().add(pan1);
                   getContentPane().add(pan2);
                   //adding the Listener     
                   jTfd.addActionListener(this);
                           jbtn7.addActionListener(this);
                   jbtn8.addActionListener(this);
                   jbtn9.addActionListener(this);
                   jbtnFT.addActionListener(this);
                   jbtn4.addActionListener(this);
                   jbtn5.addActionListener(this);
                   jbtn6.addActionListener(this);
                   jbtn1.addActionListener(this);
                   jbtn2.addActionListener(this);
                   jbtn3.addActionListener(this);
                   jbtn0.addActionListener(this);
                   validate();
    public void actionPerformed(ActionEvent ae)
                   JButton jbtn = (JButton)ae.getSource();
                   jTfd.replaceSelection( jbtn.getActionCommand() );
                   if (ae.getSource()==jbtnFT)
                        int num= Integer.parseInt(jTfd.getText());
                             int i;
                             long fact=1;
                             for(i=1; i<=num; i++)
                                       fact *=i;
                             jTfd.setText(String.valueOf(fact));
    public static void main (String arg [ ])
                   PanFrame ObjFr = new PanFrame ("Two Panel in One Frame");
                   ObjFr.setDefaultCloseOperation(EXIT_ON_CLOSE);
                   ObjFr.setSize (400, 400);
                   ObjFr.setVisible (true);
    }

  • IWork and iLife purchase with codes not valid on the new computer?

    Hi,
    last year I downloaded the iWork and iLife suites on the macbook pro provided by my school. I'm not sure how it works but I had the iWork suite and I used to update it with my Apple ID, now I can't. I just got an old macbook air (sold before the apps were included for free) and I was trying to download the suite but it's not in the purchased apps and it's not free. I used to have them, do I have to buy them again?
    Regarding the iLife suite the situation was slightly different. I basically downloaded them with some codes given me by the Apple support, do they work only for a single computer?
    Thank you!
    P.S.: In case I can't download them again, do you know if Apple offers discounts on its apps for students?

    Apple does not offer education discounts to individuals for software.
    If the Mac belonged to the school, the apps also belong to the school. If you now have your own used Mac, then you will need to buy the apps for yourself.

  • Need help with connecting a display

    My brother no longer wants his TV so I thought that maybe I could connect it to my iMac.
    He has a Mini Display port to HDMI cord and it worked between his MacBook Pro and the TV downstairs, not sure on any other TVs.
    The TV in question is a Samsung LE19R. I tried connecting it and it said "Not compatible in this mode" (Or something like that).
    So I tried fiddling with the settings, try changing the mode, nothing.
    Considering that the TV downstairs is by Sony, I thought I'd try my TV (As it's a Sony as well; KDL-19S5700), just to see. Doesn't work either.
    Pretty much just wanted to try this for the fun of it, but not permenantly because there's no where near enough room n my desk, so I was thinking it could perhaps be a future configuration if I rearrange a few things. I'm going to get a job and save up for a Mac Pro. This will take some time and tere'll probably be a new Mac Pro on the market or something else, but it would take too much time to save up for a monitor as well, so I culd use my brother's if I do manage to save up.
    So it's nothing too important, but it would be nice to try it. Any suggestions?

    Checking the manual of the Samsung, it seems to mention that you can't connect a PC via HDMI.
    I don't know why the Samsung manual would say that. If it supports HDMI (at the proper version level) then I would think it wouldn't know where the signal is coming from.  Maybe it has something to do with the EDID info (or lack of it) from the TV.
    Not sure about the Sony though.
    I have a Sony 32XBR6 hooked to my machine via HDMI and it works great (for full disclosure here, I have connected to a mac pro)
    On the iMac, I can't change the refresh rate on the secondary monitor; it's stuck at 60Hz, but I live in a PAL region, so the TV is 50Hz. Could that be the problem?
    Not sure about the refresh rate for PAL.  Just try whatever refreh rates the Displays offers to fish for one that would work.
    Also I'm sure the TV is 720p, but when I clicked "Mirror Monitors", the iMac display changed to something else, which wasn't 720p.
    You don't want to use mirrored with this arrangement.  With mirrored all the screens would have a size determined by the smallest screen.

  • Urgent-Need help with code for Master data enhancement

    hi Experts,
    I have appended YMFRGR field(Table MARC) to 0MAT_PLANT_ATTR datasource.
    The key fields in the MARC table are MATNR and WERKS.Can anybody help with the user exit to populate this field,as am pretty new to ABAP.
    Thanks in advance

    Hi,
    go through this link which has the similar problem:
    https://forums.sdn.sap.com/click.jspa?searchID=1331543&messageID=2794783
    hope it helps.
    Thanks,
    Amith

  • Need help with syncing/not playing songs

    when i plug in my ipod to the computer, the computer recognizes the ipod and says that it syncs all my music, after unplugging it, i still have all my old music on it but none of the new songs i wanted. also none of the songs play. the song title only shows, and after showing it for about a second skips to the next song title and so on not playing anything? any ideas on what the problem could be or how to fix it??

    OK so it would appear that it is not connecting to the computer at all yet.
    Is the connector of the cable FULLY seated into the iPod? When you push the plug in it goes in almost all the way in then stops and you then have to give it a pretty firm push to snap it in the rest of the way. A lot of people do not realize it goes in further.
    When fully seated, the barrel of the connector should be completely in the iPod with the white plastic of the connector butting up against the body of the shuffle.
    Patrick

  • I need help with putting notes on the ipod nano!!!!... HELP!!!...

    I have no clue how to even go about putting notes on the ipod nano but i allways get lost!!! I just got it and i need some big time help !!!
    thanks so much

    1 - Ok, to put notes onto your nano, you'll first need to enable it for disk mode. When it's plugged in, go into iTunes, and open up iPod preferences. Check the "Enable disk use" box.
    2 - In your Windoze file browser (what you click on files in), locate your iPod, which should be located in My Computer. Open that up, and locate the notes folder. That is where you can put any notes, in the form of text files, that you want.
    3 - Make the notes. iPods only recognize plain text and html files. So, when you open the text file up in a word processor, make sure to save it as a plain text file (.txt extension). Then, just drag it onto your iPod.
    In disk mode, your iPod will need to be ejected before you unplug it from your computer. Right click on it (in your My Computer folder) and click "Eject"
    -Michael

  • Newbie needing help with code numbers and if-else

    I'm 100% new to any kind of programming and in my 4th week of an Intro to Java class. It's also an on-line class so my helpful resources are quite limited. I have spent close to 10 hours on my class project working out P-code and the java code itself, but I'm having some difficulty because the project seems to be much more advanced that the examples in the book that appear to only be partly directly related to this assignment. I have finally come to a point where I am unable to fix the mistakes that still show up. I'm not trying to get anyone to do my assignment for me, I'm only trying to get some help on what I'm missing. I want to learn, not cheat.
    Okay, I have an assignment that, in a nutshell, is a cash register. JOptionPane prompts the user to enter a product code that represents a product with a specific price. Another box asks for the quanity then displays the cost, tax and then the total amount plus tax, formatted in dollars and cents. It then repeats until a sentinel of "999" is entered, and then another box displays the total items sold for the day, amount of merchandise sold, tax charged, and the total amount acquired for the day. If a non-valid code is entered, I should prompt the user to try again.
    I have this down to 6 errors, with one of the errors being the same error 5 times. Here are the errors:
    C:\PROGRA~1\XINOXS~1\JCREAT~1\MyProjects\Sales.java:50: 'else' without 'if'
    else //if invalid code entered, output message
    ^
    C:\PROGRA~1\XINOXS~1\JCREAT~1\MyProjects\Sales.java:39: unexpected type
    required: variable
    found : value
    100 = 2.98;
    ^
    C:\PROGRA~1\XINOXS~1\JCREAT~1\MyProjects\Sales.java:41: unexpected type
    required: variable
    found : value
    200 = 4.50;
    ^
    C:\PROGRA~1\XINOXS~1\JCREAT~1\MyProjects\Sales.java:43: unexpected type
    required: variable
    found : value
    300 = 6.79;
    ^
    C:\PROGRA~1\XINOXS~1\JCREAT~1\MyProjects\Sales.java:45: unexpected type
    required: variable
    found : value
    400 = 5.29;
    ^
    C:\PROGRA~1\XINOXS~1\JCREAT~1\MyProjects\Sales.java:47: unexpected type
    required: variable
    found : value
    500 = 7.20;
    ^
    And finally, here is my code. Please be gentle with the criticism. I've really put a lot into it and would appreciate any help. Thanks in advance.
    import java.text.NumberFormat; // class for numeric formating from page 178
    import javax.swing.JOptionPane; // class for JOptionOPane
    public class Sales {
    //main method begins execution ofJava Application
    public static void main( String args[] )
    double quantity; // total of items purchased
    double tax; // total of tax
    double value; // total cost of all items before tax
    double total; // total of items including tax
    double totValue; // daily value counter
    double totTax; // daily tax counter
    double totTotal; // daily total amount collected (+tax) counter
    double item; //
    String input; // user-entered value
    String output; // output string
    String itemString; // item code entered by user
    String quantityString; // quantity entered by user
    // initialization phase
    quantity = 0; // initialize counter for items purchased
    // get first code from user
    itemString = JOptionPane.showInputDialog(
    "Enter item code:" );
    // convert itemString to double
    item = Double.parseDouble ( itemString );
    // loop until sentinel value read from user
    while ( item != 999 ) {
    // converting code to amount using if statements
    if ( item == 100 )
    100 = 2.98;
    if ( item == 200 )
    200 = 4.50;
    if ( item == 300 )
    300 = 6.79;
    if ( item == 400 )
    400 = 5.29;
    if ( item == 500 )
    500 = 7.20;
    else //if invalid code entered, output message
    JOptionPane.showMessageDialog( null, "Invalid code entered, please try again!",
    "Item Code", JOptionPane.INFORMATION_MESSAGE );
    } // end if
    } // end while
    // get quantity of item user
    itemString = JOptionPane.showInputDialog(
    "Enter quantity:" );
    // convert quantityString to int
    quantity = Double.parseDouble ( quantityString );
    // add quantity to quantity
    quantity = quantity + quantity;
    // calculation time! value
    value = quantity * item;
    // calc tax
    tax = value * .07;
    // calc total
    total = tax + value;
    //add totals to counter
    totValue = totValue + value;
    totTax = totTax + tax;
    totTotal = totTotal + total;
    // display the results of purchase
    JOptionPane.showMessageDialog( null, "Amount: " + value +
    "\nTax: " + tax + "\nTotal: " + total, "Sale", JOptionPane.INFORMATION_MESSAGE );
    // get next code from user
    itemString = JOptionPane.showInputDialog(
    "Enter item code:" );
    // If sentinel value reached
    if ( item == 999 ) {
    // display the daily totals
    JOptionPane.showMessageDialog( null, "Total amount of items sold today: " + quantity +
    "\nValue of ites sold today: " + totValue + "\nTotal tax collected today: " + totTax +
    "\nTotal Amount collected today: " + totTotal, "Totals", JOptionPane.INFORMATION_MESSAGE );
    System.exit( 0 ); // terminate application
    } // end sentinel
    } // end message
    } // end class Sales

    Here you go. I haven't tested this but it does compile. I've put in a 'few helpful hints'.
    import java.text.NumberFormat; // class for numeric formating from page 178
    import javax.swing.JOptionPane; // class for JOptionOPane
    public class TestTextFind {
    //main method begins execution ofJava Application
    public static void main( String args[] )
         double quantity; // total of items purchased
         double tax; // total of tax
         double value; // total cost of all items before tax
         double total; // total of items including tax
    //     double totValue; // daily value counter
    //     double totTax; // daily tax counter
    //     double totTotal; // daily total amount collected (+tax) counter
    // Always initialise your numbers unless you have a good reason not too
         double totValue = 0; // daily value counter
         double totTax = 0; // daily tax counter
         double totTotal = 0; // daily total amount collected (+tax) counter
         double itemCode;
         double item = 0;
         String itemCodeString; // item code entered by user
         String quantityString; // quantity entered by user
         // initialization phase
         quantity = 0; // initialize counter for items purchased
         // get first code from user
         itemCodeString = JOptionPane.showInputDialog("Enter item code:" );
         // convert itemString to double
         itemCode = Double.parseDouble ( itemCodeString );
         // loop until sentinel value read from user
         while ( itemCode != 999 ) {
    * 1. variable item mightnot have been initialised
    * You had item and itemCode the wrong way round.
    * You are supposed to be checking itemCode but setting the value
    * for item
              // converting code to amount using if statements
              if ( item == 100 )
              {itemCode = 2.98;}
              else if ( item == 200 )
              {itemCode = 4.50;}
              else if ( item == 300 )
              {itemCode = 6.79;}
              else if ( item == 400 )
              {itemCode = 5.29;}
              else if ( item == 500 )
              {itemCode = 7.20;}
              else {//if invalid code entered, output message
                   JOptionPane.showMessageDialog( null, "Invalid code entered, please try again!",
                   "Item Code", JOptionPane.INFORMATION_MESSAGE );
              } // end if
         } // end while
         // get quantity of item user
         itemCodeString = JOptionPane.showInputDialog("Enter quantity:" );
    * 2.
    * You have declared quantityString here but you never give it a value.
    * I think this should be itemCodeString shouldnt it???
    * Or should you change itemCodeString above to quantityString?
         // convert quantityString to int
    //     quantity = Double.parseDouble ( quantityString );  // old code
         quantity = Double.parseDouble ( itemCodeString );
         // add quantity to quantity
         quantity = quantity + quantity;
         // calculation time! value
         value = quantity * itemCode;
         // calc tax
         tax = value * .07;
         // calc total
         total = tax + value;
         //add totals to counter
    * 3. 4. and 5.
    * With the following you have not assigned the 'total' variables a value
    * so in effect you are saying eg. "total = null + 10". Thats why an error is
    * raised.  If you look at your declaration i have assigned them an initial
    * value of 0.
         totValue = totValue + value;
         totTax = totTax + tax;
         totTotal = totTotal + total;
         // display the results of purchase
         JOptionPane.showMessageDialog( null, "Amount: " + value +
         "\nTax: " + tax + "\nTotal: " + total, "Sale", JOptionPane.INFORMATION_MESSAGE );
         // get next code from user
         itemCodeString = JOptionPane.showInputDialog("Enter item code:" );
         // If sentinel value reached
         if ( itemCode == 999 ) {
              // display the daily totals
              JOptionPane.showMessageDialog( null, "Total amount of items sold today: " + quantity +
              "\nValue of ites sold today: " + totValue + "\nTotal tax collected today: " + totTax +
              "\nTotal Amount collected today: " + totTotal, "Totals",           JOptionPane.INFORMATION_MESSAGE );
              System.exit( 0 ); // terminate application
         } // end sentinel
    } // end message
    } // end class SalesRob.

  • Need help with code for adding dates to form

    Hello forum goers
    I'm new to making forms and figured out how to auto add the date, however I need the form to change the date for every copy made.
    For example today is 06/08/2012 if I print 10 copies of the form it will output 10 pages ranging from 06/08/2012 to 06/17/2012. If code exists to do this I would be very gratefull to whoever helps, I also wouldn't mind if that is not possible for manually inputing the start / end dates.
    Currently I print 15-30 copies of the form and hand write each of the dates but I'm just getting to busy to do that. I also cannot print one a day it must be in batches.
    Thanks in advanced.

    What you are asking for is more complex than just setting the current date. Each time the form prints it has to know that it has to change the date. I would suggest doing this.
    First, setup a document level script to set the date to the current date. I suspect that you have already done this?
    Next, Create a "DidPrint" document action to increment the date.  To do this the script will need to scan the current text value of the date, add one day to it, and then reformat it.  You'll find information on this type of scripting in these articles:
    http://acrobatusers.com/tutorials/working-with-date-and-time-in-acrobat-javascr
    ipt
    http://acrobatusers.com/tutorials/working-with-date-and-time-in-acrobat-javascr
    ipt-part-2
    http://acrobatusers.com/tutorials/working-with-date-and-time-in-acrobat-javascr
    ipt-part-3
    Since the increment happenes in the Did Print you will need to print each copy individually. If you enter 10 copies in the print dialog it won't work. You have to print one at a time.  You can automate this activity with a console script.
    One of the advantages of incrementing in the DidPrint is that you can also manually enter a date and it will increment from there.
    Thom Parker
    The source for PDF Scripting Info
    pdfscripting.com
    The Acrobat JavaScript Reference, Use it Early and Often
    Then most important JavaScript Development tool in Acrobat
    The Console Window (Video tutorial)
    The Console Window(article)
    Having trouble, Why Doesn't my Script Work?

  • Help with spry not displaying using ssi

    Hi,
    I have reviewed previous tutorials and can't find where my mistake is.  I cut and pasted the code for spry onto an include file with the extention .shtml .  I pointed to the file and the header seeems to correct,
    My files are root relative
    I have a file called includes, you can view the source here
    http://crystalbeach.com/funthings/includes.shtml
    Here is my link that is supposed to be displaying the spry navigation bar.
    http://crystalbeach.com/funthings/index_erinn.shtml
    Please help!
    thanks

    http://crystalbeach.com/funthings/index_erinn.shtml
    Line 29
    <!--include file="includes.shtml"--> is simply a plain HTML comment. It doesn't do anything.
    Change to
    <!--#include virtual="/funthings/includes.shtml" -->
    This assumes that your include file is named includes.shtml and is always stored inside a folder named "funthings". Many people store includes inside a folder named "includes" in the root folder on the server.
    NOTE: the .shtml file extension only applies to the parent page calling the include file.
    The include file can have any file extension e.g. menu.monkeybutt where the include code would change to <!--#include virtual="/includes/menu.monkeybutt" -->

  • Need help with Apps misbehaving and upgrading the MacOS: The all-in-one post. ;)

    Hi there,
    So, I've been browsing the SL and Mavericks forums for the last days but although I have fetched some useful tips and answers, still need some help. Let me put it diary-style so I can be more concise ;)
    Here's my current system profile:
    iMac 27" (aluminium back- if I'm no wrong, from around late 2009-mid 2010)
    MacOS 10.6.1 Never updated.
    3.06 Ghz Intel Core2 Duo
    4Gb RAM
    LaCie Big Disk via FireWire 800
    Internet access via Ethernet port (cable)
    And here's The Issues Log:
    – Day one: First ever Kernel Panic. Restart. Nothing (apparently) wrong.
    – 3 weeks elapsed: Second Kernel Panic. Same. iMac restarts fine. Apps fine. No missing files. No misbehaviour experiences.
    – After a month or so: One morning, Skype decides on its own to stop launching. The night before, I chatted with one of my clients, fine as always, but at the next day, nothing. Computer is usually shut off for the night. And so it was that night. Updated Skype and also did all the guest account trick / repaired permissions / repair ACLs. Nothing worked. Overwrote the Skype app with a former functioning version I have in an MacOS 10.5 system. Didn't work. Now I have to chat on the MacOS 10.5 computer. No good.
    – 15 days ago or so: After realising that I no longer have my HP1515n printer (it ran out of inks and thrashed it. It costs more to refill than to buy a new one), I deleted the printer from the printers list in the System Prefs Pane.
    – Last week: Acrobat (CS4) won't launch a PDF file and freezes. Spinning beach ball. Force quit and try opening the PDF file again. Freezes again. And again. And again. With that file and every other PDF.
    Photoshop CS5 fails to open or crashes when attempting to open any jpg or tiff file. InDesign and Illustrator CS5 are frozen and had to force quit both. MacOS 10.5
    Restart the iMac thinking it is just a "common" bad day and hoping everything will be alright after the restart, but nope.
    Not only the CS5 stops working; MSOffice stops working too. Spinning beach ball. Begin to suspect of the deletion of the printer, however, I also deleted the same printer in the above mentioned 10.5 system and I'm not experiencing anything strange. Reinstalled the HP drivers but nothing remarkable happens.
    Then, try to uninstall CS5, CS4, Office, etc. Try to reinstall Acrobat CS4 and the CS5 apps. Reinstall Office. Nothing. Just Outlook works.
    Since I had to desperately meet deadlines, convinced a colleague to come over to the studio and -I know, I know- allowed me to install a copy of CS6. It seems to work fine, except for Acrobat, which randomly freezes/hangs/works and Photoshop, which works fine unless you want to open a layered file containing text layers or if you want to type text on a normal file, because it freezes as soon as the Text Tool is pressed in the toolbar, of course, spinning beach ball again.
    Well, Illustrator CS6 sometimes shows a strange black thin frame overlaid on the interface but goes away by switching to another workspace and then back to the current. InDesign CS6 seems to be fine and making PDFs as expected. However, as I said before, it is pure luck if Acrobat accepts to open the file or even if it launches. Spinning beach ball when freezing/hanging.  
    As a method for eliminating possible culprits, did a clean up of the Suitcase Fusion database, removed duplicate and a few (less than 10) corrupted fonts.
    Removed completely MSOffice reinstalled and updated. Nothing. Now I neither have MSoffice running.
    I am no rookie but I can't even imagine what can cause such amount of misbehaviour, (kernel panics have something to do? malware? lack of system updates? MacHD is damaged?) so I'm thinking of a few scenarios:
    Backing up my projects and user folder –anything else to backup? (In fact I've already done that)– and:
    1. Do a clean install. Not sure if it will be best to completely erase the whole drive or if a standard reinstallation will be enough.
    2. Take the machine to a Genius Bar to see if there's anything that can be done without major OS messes.
    3. Erase the drive and go through the Mavericks upgrading (SL to Ln to MLn to Mavcks), although not sure if this upgrade is worth yet.
    4. Replace HD for a brand new one and either step 1 or 3.
    5. As a complement, I'm thinking of adding more RAM.
    Well. It is really the first time I don't know what to do. I have work to do and would not want to face a week away from my main computer and since most of the files are CS5-6 and hence, can't move to my wife's iMac...
    Apologies if this post feels too long, but I will truly appreciate any kind of input and advice on one of more of the issues mentioned in this post.
    And if it fits best in any other forum, please also let me know.
    Cheers and thanks in advantage.

    You have to use the Base Station Menu on the Menu Bar at the very top of your screen.
    Say thanks by clicking "Kudos" "thumbs up" in the post that helped you.
    I am employed by HP

  • Video Producer needs help with code error

    Hi all!
    At the risk of getting long winded, I am a video producer who
    has in the last 6 months gotten into web development for myself and
    to offer to clients.
    I am in the process of learning DreamWeaver and like it very
    much, but I must say that the worlds of web development and video
    production are extremely different and in some ways, building a
    website is far more difficult. I have because of this, a new found
    respect for good web developers as they are worth their weight in
    gold.
    My problem today is that I added a second Quicktime video in
    the index page of an already existing site of my own and this video
    will not show up. It just displays the QT logo.
    Is someone willing to look at the code and maybe offer an
    explanation of what I am doing wrong? The site is
    www.coosbaytv.com. The issue is on the homepage and very apparent
    when you scroll to the lower half of the page. The first video is
    fine, the second (D'S MEDI-TANZ) is not.
    I am completely stumped and need to get this resolved.
    Thanks, Jay

    <I have... a new found respect for good web developers as
    they are worth
    their weight in gold.>
    You betcha! I wish everyone felt that way.
    http://www.coosbaytv.com/medi-tanz.mov
    Page cannot be found.
    Upload your QT movie to the server.
    --Nancy O.
    Alt-Web Design & Publishing
    www.alt-web.com
    "coosbaytv" <[email protected]> wrote in
    message
    news:fc1c1v$rmv$[email protected]..
    > Hi all!
    >
    > At the risk of getting long winded, I am a video
    producer who has in the
    last
    > 6 months gotten into web development for myself and to
    offer to clients.
    > I am in the process of learning DreamWeaver and like it
    very much, but I
    must
    > say that the worlds of web development and video
    production are extremely
    > different and in some ways, building a website is far
    more difficult. I
    have
    > because of this, a new found respect for good web
    developers as they are
    worth
    > their weight in gold.
    >
    > My problem today is that I added a second Quicktime
    video in the index
    page of
    > an already existing site of my own and this video will
    not show up. It
    just
    > displays the QT logo.
    >
    > Is someone willing to look at the code and maybe offer
    an explanation of
    what
    > I am doing wrong? The site is www.coosbaytv.com. The
    issue is on the
    homepage
    > and very apparent when you scroll to the lower half of
    the page. The first
    > video is fine, the second (D'S MEDI-TANZ) is not.
    >
    > I am completely stumped and need to get this resolved.
    >
    > Thanks, Jay
    >

  • Need help with code

    Hi,
    I'm new to java, i'm creating java analog clock application. but i'm getting so many errors. i still try to figur out what are those. can someone please help me with this code. Thank you
    here is my code
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import java.text.*;
    import javax.swing.*;
    //The main class
    public class AnalogClock extends JFrame
    // Initialize all the variables
    SimpleDateFormat f_s = new SimpleDateFormat ("ss", Locale.getDefault());
    SimpleDateFormat f_m = new SimpleDateFormat ("mm", Locale.getDefault());
    SimpleDateFormat f_h = new SimpleDateFormat ("hh", Locale.getDefault());
    SimpleDateFormat standard = new SimpleDateFormat ("HH:mm:ss", Locale.getDefault());
    int xs, ys, xm, ym, xh, yh, s, xcenter, ycenter, m, h, x, y, mouse_x, mouse_y;
    String temp;
    Dimension d;
    Date now;
    Thread thr = null;
    Image im;
    Boolean M = false;
    Graphics gIm;
    Dimension dIm;
    int sx, sy, sx2, sy2;
    Color digital = Color.blue, hour = Color.blue, minute = Color.yellow,
    second = Color.green, circle = Color.red, hours = Color.blue, mute_logo = Color.green;
    // paint(): the main part of the program
    public void paint(Graphics g)
    d = getSize();
    xcenter = d.width/2;
    ycenter = d.height/2;
    x = d.width;
    y = d.height;
    if(im == null)
    im = createImage(x, y);
    gIm = im.getGraphics();
    dIm = new Dimension(x, y);
    // Get the current timestamp
    now = new Date();
    // Get the seconds
    temp = f_s.format(now);
    s = Integer.parseInt(temp);
    temp = f_m.format(now);
    m = Integer.parseInt(temp);
    temp = f_h.format(now);
    h = Integer.parseInt(temp);
    // Calculate all the positions of the hands
    xs = (int) (Math.cos(s * Math.PI / 30 - Math.PI / 2) * 45 + xcenter);
    ys = (int) (Math.sin(s * Math.PI / 30 - Math.PI / 2) * 45 + ycenter);
    xm = (int) (Math.cos(m * Math.PI / 30 - Math.PI / 2) * 40 + xcenter);
    ym = (int) (Math.sin(m * Math.PI / 30 - Math.PI / 2) * 40 + ycenter);
    xh = (int) (Math.cos((h * 30 + m / 2) * Math.PI / 180 - Math.PI / 2) * 30 + xcenter);
    yh = (int) (Math.sin((h * 30 + m / 2) * Math.PI / 180 - Math.PI / 2) * 30 + ycenter);
    // Refresh the image
    gIm.setColor(getBackground());
    gIm.fillRect(0, 0, dIm.width, dIm.height);
    // Draw the circle of the clock
    gIm.setColor(circle);
    gIm.drawOval(0, 0, d.width-1, d.height-1);
    gIm.setColor(hours);
    // Draw the stripes of the hours
    for(int i = 0;i<12;i++)
    sx = (int) (Math.cos((i * 30) * Math.PI / 180 - Math.PI / 2) * 47 + xcenter);
    sy = (int) (Math.sin((i * 30) * Math.PI / 180 - Math.PI / 2) * 47 + xcenter);
    sx2 = (int) (Math.cos((i * 30) * Math.PI / 180 - Math.PI / 2) * 49 + xcenter);
    sy2 = (int) (Math.sin((i * 30) * Math.PI / 180 - Math.PI / 2) * 49 + xcenter);
    gIm.drawLine(sx, sy, sx2, sy2);
    // Draw the time on the top of the clock
    gIm.setColor(digital);
    gIm.drawString(standard.format(now), 25, 30);
    // Draw the mute logo
    Mute m = new Mute(M, gIm);
    // Draw the hands
    // Seconds
    gIm.setColor(second);
    gIm.drawLine(xcenter, ycenter, xs, ys);
    // Minutes
    gIm.setColor(minute);
    gIm.drawLine(xcenter, ycenter-1, xm, ym);
    gIm.drawLine(xcenter-1, ycenter, xm, ym);
    // Hour
    gIm.setColor(hour);
    gIm.drawLine(xcenter, ycenter-1, xh, yh);
    gIm.drawLine(xcenter-1, ycenter, xh, yh);
    // Paint the generated image on the screen
    if(im != null)
    g.drawImage(im, 0, 0, null);
    if(M == false)
    play(getCodeBase(), "Sound/Click.wav");
    public void update(Graphics g)
    paint(g);
    class Mute
    Mute(Boolean mute, Graphics g)
    g.setColor(mute_logo);
    Polygon p = new Polygon();
    p.addPoint(1, 7);
    p.addPoint(6, 2);
    p.addPoint(6, 12);
    g.fillPolygon(p);
    g.drawLine(7, 5, 7, 9);
    g.drawLine(9, 4, 9, 10);
    g.drawLine(11, 3, 11, 11);
    if(mute == true)
    g.drawLine(13, 3, 1, 11);
    /* // All the mouse events
    public void mousePressed(MouseEvent evt)
    mouse_x = evt.getX();
    mouse_y = evt.getY();
    if(mouse_x <= 11 && mouse_x >= 1 && mouse_y <= 12 && mouse_y >= 2)
    if(M == true)
    M = false;
    } else {
    M = true;
    repaint();
    public void mouseReleased(MouseEvent evt){}
    public void mouseEntered(MouseEvent evt){}
    public void mouseExited(MouseEvent evt){}
    public void mouseClicked(MouseEvent evt){}
    }

    There is a gross misconception among the new and learning programmers that a lot of code is good and once you put that last close scope in place that things are wonderful because you have all the code down...
    Please repeat this: NO, short debugged runs and incremental builds are better.
    As a matter of fact, that is so important, go back and say it again and again until it really truly sinks in.
    This concept is really pounded into your soul when you program in assembler--probably an ailment of the new generation of programmers, they never have had to do assembler or machine coding--but any time you get more than about 20 lines of code that hasn't been checked for bugs, you should start thinking... "Oh, do I really have the skills and patience to go back and debug (yes, actually use the debugger to step through it all.) that big of mess?" The biggest project is just like eating an elephant, you do it one small bite at a time over as long a time as it takes--you don't cook half the elephant and sit down and expect to eat it in one meal; neither do you sit down and decide to code a whole program and then debug it. You just don't have the skill to do it.
    When you modify someone else's code, the same is true--small changes and debug as you change. Making all the changes you want, then debugging just runs into a huge error file of related problems that are basically indiscernible from each other because many of them are probably related.
    Most of the request for "Help, I cannot get this to run." Also contain the words: "I just finished coding..." That statement in and of itself is one of the great flawed concepts that anyone can have--coding is complete when you have an acceptable release candidate, and then only until you decide or are asked to make further changes.
    Work in small blocks of code and incrementally build a project--your frustration levels will be much less. And as you gain skill, increase the size of the code blocks (I had a friend in college that never had 5 consecutive lines of code compile--ever! He works for MS now.) and get to know your debugger. Your debugger is your friend, if you've not been introduced to your debugger, then get acquainted soon! Like maybe before you even try to cut another piece of code.
    On the other side of things... cheer up, we've all been there and learned the lessons... some lessons just come harder than others... make your life less frustrating, it's a lot more fun and enjoyable.

  • SSL - Default SSL context init failed: null - need help with code

    Hi!
    Once Again I have problems with SSL.
    I read something about SSL here:
    http://www.javaalmanac.com/egs/javax.net.ssl/Server.html
    Now I tried to test this stuff, that resulted in this program (I simply tried to put the SSL stuff from the above code in a small skeleton):
    import java.io.*;
    import java.net.*;
    import java.security.*;
    import javax.net.ssl.*;
    import javax.net.*;
    public class MyServer
         public static void main(String arguments[])
         try
              int port = 443;
              ServerSocketFactory ssocketFactory = SSLServerSocketFactory.getDefault();
              ServerSocket ssocket = ssocketFactory.createServerSocket(port);
              // Listen for connections
              Socket socket = ssocket.accept();
              System.out.println("Connected successfully");
              // Create streams to securely send and receive data to the client
              InputStream in = socket.getInputStream();
              OutputStream out = socket.getOutputStream();
              // Read from in and write to out...
              // Close the socket
              in.close();
              out.close();
         catch(IOException e)
              System.out.println("GetMessage() = "+e.getMessage());
              e.printStackTrace();
    }     Now I compiled this stuff with : 'javac MyServer.java' - there were no errors. After this I run the program
    with the following command (also taken from java almanac):
    'java -Djavax.net.ssl.keyStore=mySrvKeystore -Djavax.net.ssl.keyStorePassword=123456 MyServer'
    But if I run it, it reports:
    "GetMessage() = Default SSL context init failed: null
    java.net.SocketException: Default SSL context init failed: null
    at javax.net.ssl.DefaultSSLServerSocketFactory.createServerSocket(Dasho
    6275)
    at MyServer.main(MyServer.java:15)"
    createServerSocket() seems to be the wrong line, but what is wrong with it.
    Is there any mistake in my code ?
    Btw. I created my keystore etc. according to the instructions at
    http://forum.java.sun.com/thread.jsp?forum=2&thread=528092&tstart=0&trange=15
    Any help appreciated
    Greets
    dancing_coder

    I got this error last week.
    The problem was that the keystore I was pointing to, was in other location, so it could not initialize the default context.
    I had defined ...
    String CLIENT_CERTIFPATH = getParam("client.certificate.path", "/users/pridas/myKeystoreFile");
    // getParam extracts the location of the keystore from a text file which contains some configuration parameters. The default value will be /users/pridas/myKeystoreFile
    In my case, I will try to develop a secure SOAP conexion using certificates.
    Before to try the conexion, I defined ...
    System.setProperty("javax.net.ssl.trustStore", CLIENT_CERTIFPATH);
    System.setProperty("javax.net.ssl.keyStore", CLIENT_CERTIFPATH);
    ... and the problem when I got this error ... the keystore file was not in the correct location.
    That was how I resolved this error.
    I hope everybody will be oriented about this kind of errors.
    Salu2.

Maybe you are looking for