Displaying a quiz in midlet

hello everyone,
i am new to j2me, can anyone help how to develop a quiz in a j2me midlet. as i am unable to print not more than one question using forms.
thanks in advance
regards
pallavi

public class CheckBoxExample extends MIDlet implements CommandListener {
     private Display display;
     private Form form1,form2;
     private Command exit, choose;
     private ChoiceGroup technology,language;
     private int index1,index2;
     public CheckBoxExample() {
          form1 = new Form("Technologies");
                form2 = new Form("Languages");
          technology = new ChoiceGroup("Select Technology Which You Know", Choice.MULTIPLE);
                language = new ChoiceGroup("Select the language you mainly using",Choice.MULTIPLE);
          exit = new Command("Exit", Command.EXIT, 1);
          choose = new Command("Choose", Command.SCREEN, 2);          
     public void startApp() {
          display = Display.getDisplay(this);
          technology.append("JAVA", null);
          technology.append("J2ME", null);
          technology.append("J2EE", null);
          technology.append("JSF", null);
                language.append("JAVA", null);
          language.append(".NET", null);
          language.append("C++", null);
          language.append("Multimedia", null);
          index1 = form1.append(technology);
                index2 = form2.append(language);
          form1.addCommand(exit);
          form1.addCommand(choose);
          form1.setCommandListener(this);
          display.setCurrent(form1);
                form2.addCommand(exit);
          form2.addCommand(choose);
          form2.setCommandListener(this);
          display.setCurrent(form2);
     public void pauseApp(){}
     public void destroyApp(boolean unconditional){
          notifyDestroyed();
     public void commandAction(Command c, Displayable displayable){
          String label = c.getLabel();
          if (label.equals("Choose")) {
               StringItem message1[] = new StringItem[technology.size()];
                        StringItem message2[] = new StringItem[language.size()];
               boolean get1[] = new boolean[technology.size()];
                        boolean get2[] = new boolean[language.size()];
               technology.getSelectedFlags(get1);
                        language.getSelectedFlags(get2);
               for (int i = 0; i < get1.length; i++) {
                    if (get1) {
                         message1[i] = new StringItem("Your Choice is: ", technology.getString(i));
                         form1.append(message1[i]);
for (int i = 0; i < get2.length; i++) {
                    if (get2[i]) {
                         message2[i] = new StringItem("Your Choice is: ", language.getString(i));
                         form2.append(message2[i]);
               form1.delete(index1);
form1.delete(index2);
               form1.removeCommand(choose);
form2.delete(index1);
form2.delete(index2);
               form2.removeCommand(choose);
          } else if (label.equals("Exit")){
               destroyApp(false);
here is my code. only one question is displaying her
Edited by: Pallavi81 on Nov 17, 2008 11:11 PM

Similar Messages

  • Problem Displaying Japanese chars in MIDlet

    Hi,
    I want to internationalize my MIDlet application.
    For that I am using ResourceBundle ,it works fine with J2ME kit.I know it works fine because Jdk1.3 supports displaying unicode characters.I think KVM doesn't support unicode characters.If anybody knows something then please reply immediately.
    Regards
    Vivek

    [vivek_kurundkar],
    Currently MIDP v1.0 only states that the ISO Latin 1 character encoding must be supported by all MIDP implementation i.e. mandatory to support the ISO Latin 1 char encoding but not all other locales.
    The locale is defined in the microedtion.locale system proprety and localization must be provided by the implementation i.e. for example the device manufacturer who provides the kVM for their device.
    In your case, you have a need for the Japanese locale and thus the emulator/kVM of the device must provide the Japanese locale.
    Which kVM emulator/device are you testing your CLDC/MIDP application with?
    Allen Lai
    Developer Technical Support
    SUN Microsystems
    http://www.sun.com/developers/support/

  • Display prayer times in midlet

    hi all,
    can anyone tel me. how to display prayer times in a midlet from the text format.
    here i have saved my prayer times in a text file. i am not able to read those.
    thanks in advance

    i have created a midlet.. which displays the prayer times. where as here i will read the content from a bin file. that is converted from a text file. but here i want to display using the text file directly without conversion of text to bin.
    its not reading actually
    int index=dataChoice.getSelectedIndex();
                String indexString=dataChoice.getString(index).trim()+".bin";this is the code to read the bin file.
    thanks in advance

  • Displaying Image (*png) in MIDlet

    I have encountered the following error when i try to display a *png file using ImageItem.
    IOException
    try
    Image image = Image.createImage("/BizAuto.png");
    mMainForm.append(new ImageItem(null, image, ImageItem.LAYOUT_CENTER, null));
    catch (java.io.IOException ioe) {
    System.out.println(ioe);
    System.out.println("Unable to locate or read .png file");
    It can't read my image file, and would give the IOException.
    Was wondering is there a specify directory which i have to put my image file in?
    Been looking at the code, but still can't find what's wrong.

    Sorry ... as i really need help ... Could somebody help me?
    Thanks alot ...

  • Quiz Results Analyzer - Maximum Records can Display?

    We have correctly configured Captivate 7 to store and retrieve records and display in Quiz Analyzer. 
    Is there any idea on how many student record data, or maximum records can be displayed, hundreds, thousands?
    Thank You
    iaustin

    Hi,
    There is a link to the free Quiz Results Analyzer software at the bottom of this page: http://help.adobe.com/en_US/captivate/cp/using/WS365a66ad37c9f510-326cdb51265c9c0730-8000. html
    It does not state whether you can download the results on multiple computers, but I would think so. It does state
    "Note: To use Adobe Captivate Quiz Results Analyzer, you do not require Adobe Captivate installed on your machine."

  • How to display the last value of a field in a group in the group header

    I need to display the last quiz score from a group of quiz scores as part of the header of a group of units (the quiz score values are in the detail record).  I can not use the group footer, which would be the natural place to find the last value.  It must be in the group header because there will be a subsequent group within the unit group.  In other words, the grouping is as follows:
    Unit Group Header (Display last quiz score in unit)
    SubUnit Group Header (Display other detail summaries)
    Detail Record (including quiz score)
    SubUnit Group Footer
    Unit Group Footer
    While there is a minimum/maximum summary function, there is not a first/last function.
    Fuskie
    Who is constantly amazed at the ability of users to request report features that are not easily implented through Crystal Reports...

    Hi Fuskie,
    One suggestion to display the last quiz score in the Group Header, other than what had already been suggested, will be to use a linked subreport in the Group Header. It is not an efficient way to display the information, but it could do the trick.
    Another suggestion will be to insert a subreport in the report header, then store the last quiz score in an array for each group, then share it with the main report and display the  values in the appropriate group. In this way it will only connect twice to the data source, one for the main report and once for the subreport, instead of multiple connection for each group.
    Finally, the most efficient way will be to have this value calculated on the database side using a command object or a stored procedure.
    Patrick

  • Midlet gets null values from servlet

    hey,
    based on one of the source code examples on the java.sun.com website i made a midlet/servlet application. the midlet is sending a product id to the servlet, the servlet queries the database and shows the productinformation, the midlet reads the servlet output and displays it on his midlet form
    when i invoke the servlet in my browser: http://localhost:8080/Magazijn/query?product=1 then everything works fine (i see: Product Name : Deur). when the midlet is invoking the servlet i see Product Name : null
    after hours of searching the only thing i could come up with is that the servlet isn't passing the string retrieved from the resultset to the midlet
    the strange thing is that when i papss a normal string, for instance:
    String test = "test";
    out.println(test);
    that he shows this correct both in my browser and midlet
    when i do this:
    prodName = resutl.getString("name");
    out.println(prodName);
    i see "Deur" in my browser, but i see "null" in my midlet
    anyone can help me?
    here's the servlet source:
    import java.io.*;
    import java.sql.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.Date;
    public class Magazijn extends HttpServlet {
    public void doGet(HttpServletRequest request,
              HttpServletResponse response)
                        throws IOException, ServletException {
              doPost(request,response);
    public void doPost(HttpServletRequest request,
              HttpServletResponse response)
                        throws IOException, ServletException {
         String url="jdbc:mysql://localhost/test?user=root&password=root";
         Connection con = null;
         Statement stmt;
         ResultSet rs;
         String query;
         int prodId;
         String prodNaam;
         String prodPlaats;
         String prodAantal;
         response.setContentType("text/plain");
         PrintWriter out = response.getWriter();
         BufferedReader br = request.getReader();
         String buf = br.readLine();
         try {
                   //laden van de mysql driver
                   Class.forName("com.mysql.jdbc.Driver");
                   //maken van connectie met database
                   con = DriverManager.getConnection (url, "root", "root");     
                   //aanmaken van statement object
                   stmt = con.createStatement();
                   //nakijken welke naam we zoeken van product
                   String prod = request.getParameter("product");
                   //uitvoeren van query en die opvangen in een resultset
                   query = "SELECT * from onderdelen where id="+prod;
                   ResultSet result = stmt.executeQuery(query);
                   result.next();
                   prodId = result.getInt("id");
                   prodNaam = result.getString("naam");
                   prodPlaats = result.getString("plaats");
                   prodAantal = result.getString("aantal");
              out.println(new Date());
              out.println("");
                   out.println("Product ID: "+prodId);
                   out.println("Productnaam: "+prodNaam);
                   out.println("Plaats: "+prodPlaats);
                   out.println("Aantal: "+prodAantal);
              catch(ClassNotFoundException e) {
                   out.println("Could not load database driver: " + e.getMessage());
              catch(SQLException e) {
                   out.println("SQLException caught: " + e.getMessage());
              finally {
                   //sluiten database connectie
                   try {
                        if (con != null) con.close();
                   catch (SQLException e) {}
    here's the midlet source:
    import javax.microedition.rms.*;
    import javax.microedition.lcdui.*;
    import javax.microedition.midlet.*;
    import javax.microedition.io.*;
    import java.io.*;
    import java.util.Vector;
    public class MagazijnMidlet extends MIDlet implements CommandListener {
    Display display = null;
    List menu = null;
    TextBox input = null;
    String prodid = null;
    String url = "http://localhost:8080/Magazijn/query";
    static final Command backCommand = new Command("Terug", Command.BACK, 0);
    static final Command submitCommand = new Command("Verstuur", Command.OK, 2);
    static final Command exitCommand = new Command("Afsluiten", Command.STOP, 3);
    String currentMenu = null;
    public MagazijnMidlet() { }
    public void startApp() throws MIDletStateChangeException {
    display = Display.getDisplay(this);
    menu = new List("Maak uw keuze", Choice.IMPLICIT);
    menu.append("Opvragen product gegevens", null);
    menu.addCommand(exitCommand);
    menu.setCommandListener(this);
    mainMenu();
    public void pauseApp() { }
    public void destroyApp(boolean unconditional) {
    notifyDestroyed();
    void mainMenu() {
    display.setCurrent(menu);
    //Vraag om productnummer op te geven
    public void askProdid() {
    input = new TextBox("Geef Productnummer:","", 5, TextField.ANY);
    input.addCommand(submitCommand);
    input.addCommand(backCommand);
    input.setCommandListener(this);
    input.setString("");
    display.setCurrent(input);
    //Maken connectie midlet + verwerking
    void invokeServlet(String url) throws IOException {
    HttpConnection c = null;
    InputStream is = null;
    OutputStream os = null;
    StringBuffer b = new StringBuffer();
    TextBox t = null;
    try {
    c = (HttpConnection)Connector.open(url);
    c.setRequestMethod(HttpConnection.POST);
    c.setRequestProperty("IF-Modified-Since",
         "20 Jan 2001 16:19:14 GMT");
    c.setRequestProperty("User-Agent",
         "Profile/MIDP-1.0 Configuration/CLDC-1.0");
    c.setRequestProperty("Content-Language", "en-CA");
    // send request to the servlet.
    os = c.openOutputStream();
    String str = "product="+prodid;
    byte postmsg[] = str.getBytes();
    System.out.println("Length: "+str.getBytes());
    for(int i=0;i<postmsg.length;i++) {
    os.write(postmsg);
    // or you can easily do:
    //os.write(("product="+prodid).getBytes());
    os.flush();
    // receive response and display it in a textbox.
    is = c.openInputStream();
    int ch;
    while((ch = is.read()) != -1) {
    b.append((char) ch);
    System.out.print((char)ch);
    Form formProdGeg = new Form ("Gegevens product");
    StringItem infoItem = new StringItem("",b.toString());
    formProdGeg.append (infoItem);
    formProdGeg.addCommand (backCommand);
    formProdGeg.setCommandListener (this);
    display.setCurrent (formProdGeg);
    } finally {
    if(is!= null) {
    is.close();
    if(os != null) {
    os.close();
    if(c != null) {
    c.close();
    display.setCurrent(t);
    // event handler
    public void commandAction(Command c, Displayable d) {
    String label = c.getLabel();
    if(label.equals("Afsluiten")) {
    destroyApp(true);
    } else if (label.equals("Terug")) {
    mainMenu();
    } else if (label.equals("Verstuur")) {
    prodid = input.getString();
    try {
    invokeServlet(url);
    }catch(IOException e) {}
    } else {
    askProdid();
    tia
    lee

    Hi,
    first for some efficeincy, in your place your connection to the database in the init() method so you can have on instance of the connection.
    in your midlet place the ui initialization in its constructor
    ok, Why dont you try the query in the url
    i.e http://localhost:8080/Magazijn/query=";
    then as you input the product id without setting requests
    c = (HttpConnection)Connector.open(url+productid);
    i think it will work properly
    tell me what happens with you

  • Error in running MIDlet

    Hi, all
    I have a problem around MIDlet.
    Here, the MIDlet source code :
    import javax.microedition.lcdui.*;
    import javax.microedition.midlet.*;
    import javax.microedition.io.*;
    import java.io.*;
    public class BolaMidlet extends Form implements CommandListener
    +{     +
    private Display display;
    private static final Command cmExit = new Command("Keluar", Command.EXIT, 1);
    private static final Command cmSubmit = new Command("Login", Command.OK, 1);
    private BolaMidlet midlet;
    private TextField tfUsername;
    private TextField tfMajor;
    private String result;
    public BolaMidlet(BolaMidlet midlet, Display display)
    +{+
    super("BolaMidlet");
    this.midlet = midlet;
    this.display = display;
    tfUsername = new TextField("Username", "", 20, TextField.ANY);
    tfMajor = new TextField("Major", "", 20, TextField.ANY);
    append(tfUsername);
    append(tfMajor);
    addCommand(cmExit);
    addCommand(cmSubmit);
    setCommandListener(this);
    +}+
    public void startApp()
    +{+
    display.setCurrent(this);
    +}+
    public void pauseApp()
    +{+
    display.setCurrent(null);
    +}+
    public void destroyApp(boolean unconditional)
    +{+
    +}+
    public void exitMIDlet()
    +{+
    destroyApp(false);          
    +}     +
    public void commandAction(Command c, Displayable s)
    +{+
    if(c == cmExit)
    +{+
    midlet.exitMIDlet();
    +}+
    else if(c == cmSubmit)
    +{+
    try
    +{+
    submit(tfUsername.getString(), tfMajor.getString());
    +}catch(Exception e)+
    +{+
    e.printStackTrace();
    +}+
    +}          +
    +}+
    public void submit(String user, String major)
    throws IOException
    +{+
    String url = "http://localhost:8080/hello/sayhello?user=user&pass=major";
    HttpConnection hc = null;
    StringBuffer sb = null;
    InputStream is = null;
    try
    +{+
    hc = (HttpConnection)Connector.open(url, Connector.READ_WRITE);
    hc.setRequestMethod(HttpConnection.GET);
    hc.setRequestProperty("User-Agent", "Profile/MIDP-2.1 Configuration/CLDC-1.1");
    hc.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
    if(hc.getResponseCode() == HttpConnection.HTTP_OK)
    +{+
    sb = new StringBuffer();
    int ch;
    is = hc.openInputStream();
    while((ch = is.read()) != -1)
    sb.append((char)ch);
    +}+
    else
    +{+
    System.out.println("Network error");
    +}     +
    +}catch(IOException e)+
    +{+
    e.printStackTrace();
    if(hc != null)
    hc.close();
    if(sb != null)
    result = sb.toString();
    if(is != null)
    is.close();
    +}finally+
    +{+
    if(is != null)                    
    is.close();                    
    if(sb != null)               
    result = sb.toString();                    
    if(hc != null)                    
    hc.close();                    
    +}+
    +}+
    when I compiled it, there was no problem.
    But, when I launched it on the emulator
    there was an error in WTK console like this :
    Unable to create MIDlet BolaMidlet
    java.lang.IllegalAccessException
    at com.sun.midp.midlet.MIDletState.createMIDlet(34)+
    at com.sun.midp.midlet.Selector.run(22)+
    and then the emulator said : BolaMidlet, BolaMidlet exception : java.lang.IllegalAccessException
    can someone help me to solve this ?
    I really need help for this one.
    Thank You,
    Best Regards,
    CHi
    Edited by: ichiwan on Sep 30, 2007 11:23 AM

    {color:#000080}The code you have posted is for a class that extends Form, not MIDlet.
    To post code, use code tags --{color} [code]CODE[/code] {color:#000080}is displayed as CODEPlease do not try to format parts of your code as bold or italic as that reduces the readability still more.
    db{color}

  • Small Branch Aware Quiz Returning NaN Results

    I'm trying to use the Branch Aware function to constuct a quiz for 3 different tracks that people can choose. My real file is not working, so I created a small example, and it's not working either. Here is a screenshot of the branching view to give a sense for the flow:
    When I hit the quiz for branch 1, I answer it correctly, and the quiz results show this:
    As far as I can tell, it's the same for all three branches.
    Feel free to download the file and tell me where I'm going wrong. This is just my first time, so I'm sure there's something I've overlooked...  You can find the file here: http://www.theharagans.com/captivate7/BranchingQuizTest.cptx
    Many thanks in advance!

    UPDATE with a REAL SOLUTION!
    Okay, my intention of having a branching quiz was to have a student take 1, some, or all (their choice) of a multiple-track module, with each track having its own quiz. My flaw originated in that I had the action on the last quiz slide for each branch to go to the quiz results slide, however, if the action on the last quiz slide for a branch is to go back to the point at which a student picks which module they want, the quiz doesn't break.
    What I ended up doing was creating a button on the "menu" slide that takes the student to the quiz results. That HAS to be the last action the student takes before they're done with the module. If the module in any way loops back AFTER the quiz results are displayed, the quiz breaks.
    So the branching view now looks like this, and it works for taking multiple tracks in the same iteration of the training.

  • Quiz result not showing up in Edge

    Hi there Edgers
    Really hoping someone can help me out with this problem. I've used Redesigns code(Seen Below) to design a quiz in Animate.
    I have two problems, when the first question is answered, it skips to the 3rd question instead of the 2nd. I am not sure why this is as I have have checked for overlapping buttons, there are none and it does not occur on any other questions, only the first. Second problem is the quiz reult is not showing up at the end, I have the "grade" and "result" divs in my timeline but when they are reached they do not change to display the quiz results.
    Help would be much appeciated
    i = 0;
    sym.$("btn4","btn24","btn34","btn44","btn54","btn64","btn74").click(function(){
              i++;
              sym.play("s" + i);
              if (i==1){
                        q1 = 10;
                        //sym.$("question1").html(q1);
              if (i==2){
                        q2 = 10;
                        //sym.$("question2").html(q2);
              if (i==3){
                        q3 = 10;
                        //sym.$("question3").html(q3);
              if (i==4){
                        q4 = 15;
                        //sym.$("question4").html(q4);
              if (i==5){
                        q5 = 15;
                        //sym.$("question5").html(q5);
              if (i==6){
                        q6 = 20;
                        //sym.$("question6").html(q6);
              if (i==7){
                        q7 = 20;
                        //sym.$("question7").html(q7);
              var FinalScoreHolder = q1 + q2 + q3 + q4 + q5 +q6 +q7;
              if (i=7){
                        //var FinalScoreHolder = q1 + q2 + q3;
                        sym.$("grade").html("You scored "+FinalScoreHolder+"%");
                        if (FinalScoreHolder >= 90) {
                        // play the timeline from the given position (ms or label)
                        sym.play("pass");
                        } else {
                        // play the timeline from the given position (ms or label)
                        sym.play("fail");
    As a side note, this quiz appears at the end of a 8 section mulitmedia learning environment. The code obove is the only code present in the "creationcomplete" window, the rest is done in the timeline.
    George

    In you if statement you need to change  the if statement from i=7 to i==7;  when you compare you need the double equal sign.
    var FinalScoreHolder = q1 + q2 + q3 + q4 + q5 +q6 +q7;
              if (i==7){
                        //var FinalScoreHolder = q1 + q2 + q3;
                        sym.$("grade").html("You scored "+FinalScoreHolder+"%");
                        if (FinalScoreHolder >= 90) {
                        // play the timeline from the given position (ms or label)
                        sym.play("pass");
                        } else {
                        // play the timeline from the given position (ms or label)
                        sym.play("fail");

  • Communication between MIDlets within the MIDlet suite.

    Hi Friends,
    I'm using WTK 2.2. I'm planning to have two MIDlets within the same MIDlet suite.
    I had two MIDlet files but after creating the Jar package , In the display screen, Only one MIDlet is displayed for launching.
    Please guide me the steps. If there is a local variable int i; then, how I do check the value of the variable between the different MIDlets?
    Please guide me on the steps .
    Thanks,
    Ravi.

    Here's the source code:
    import javax.microedition.midlet.MIDlet;
    import javax.microedition.lcdui.*;
    public class A extends MIDlet
         public int i=10;
         public A()
         protected void startApp()
         protected void pauseApp()
         protected void destroyApp(boolean unconditional)
    import javax.microedition.midlet.MIDlet;
    import javax.microedition.lcdui.*;
    public class B extends MIDlet
         public B()
         protected void startApp()
              A a=new A();
              a.i=10;
              System.out.println(a.i); //throws SecurityException at this line.
         protected void pauseApp()
         protected void destroyApp(boolean unconditional)
    }

  • How to parse xml file in midlet

    Hi Guys,
    i wish to parse xml file and display it in my midlet. i found api's supporting xml parsing in j2se ie., in java.net or j2se 5.0. Can u please help me what package to use in midlet?
    how to parse xml info and display in midlet? Plz reply soon......Thanks in advance....

    i have exactly the same problem with KXml2, but using a j2me-polish netbeans project.
    i've tried to work around with similar ways like you, but none of them worked. now i've spent 3 days for solving this problem, i'm a bit disappointed :( what is wrong with setting the downloaded kxml2 jar path in libraries&resources?
    screenshot

  • Why do quiz slides not work in LMS?

    Using Captivate 7. Scorm 2004. I added three multiple choice quiz slides to the course, interspersed between content pages, to act as review questions. Each quiz slide has a Submit and a Clear button.
    When I reloaded the updated course, now with the quiz slides, to the LMS (Cornerstone -stage environment), the options on the quiz slides are not clickable and the Submit and Clear buttons are missing.
    My settings are:
      Completion - based on slide views - 100%
      Success - based on slide views - 100%
      Quiz - "Optional - user can skip"
      Pass/Fail - 0% required to pass
      If Failing: Allow infinite attempts - checkbox (but I've also tried 1 attempt)
    Thanks!

    Thanks, Lieve. Actually, I think the reason that the LMS did not correctly display the quiz slides is because it had already marked me as "complete" (I had taken the course multiple times previously.) Plus in all the various versions I re-loaded to our Stage environment, I kept changing quiz settings, etc., and I think the poor LMS was just so confused. So after I made a few more changes to the course (see below) and logged in as a different user, the course and quiz slides displayed correctly.
    I made these changes to quiz settings in Captivate:
      - I based completion on only "Slides viewed" -- not on "Quiz is passed"
      - On the "Pass or Fail" settings, I changed "Go to next slide" to "Continue"
        and under  "If failing grade," I changed "1 attempt" to "infinite attempts."
    I also removed the reportable click box from slide 1.
    So I'm not sure which of these changes solved the problem, but the course is working correctly now, thankfully.

  • AS3 how to save quiz score with SharedObject

    I'm working on a quiz using AS3 on timeline. I can't figure out how to save the score at the end of the quiz.  The result of quiz is displayed by its dynamic text box (out_score.text), but it isn't saved along with the rest of information. Please help!
    When I go back to section I, all information is displayed, but quiz score goes back to zero (0).
    I have section I, which collects user information. Section II, 25 question quiz, and section III, which displays information and score.
    SECTION ONE (labeled "inf"):
    // score variable
    var i:Number=0;
    stage.showDefaultContextMenu=false;
    // declaring sharedObject
    var userInf:SharedObject = SharedObject.getLocal("userInformation", "/");
    if(userInf.data.userName != undefined) {
    gotoAndStop("closing");
    // inf button
    inf_bt.addEventListener(MouseEvent.CLICK, saveData);
    function saveData(evt:MouseEvent): void
    gotoAndStop("pg1"); // here starts the quiz
    // SECTION II, for each correct answer
    i++;
    SECTION III (labeled "closing").
    out_score.text = i.toString(); // dynamic box
    userInf.data.userScore = out_score.text;
    out_score.text = userInf.data.userScore;
    // button saves score and user's information
    save_bt.addEventListener(MouseEvent.CLICK, gotoResults);
    function gotoResults(evt:MouseEvent): void
    userInf.flush();
    gotoAndStop("intro");
    Thanks for any help!
    German

    Kglad:
    userInf.data.userScore exists only on section III ("closing"). Here is a short version of my file.
    //INTRODUCTION
    stop();
    var i:Number=0;
    intro_bt.addEventListener(MouseEvent.CLICK, gotoInf);
    function gotoInf(evt:MouseEvent): void
    gotoAndStop("inf");
    //INFORMATION
    stop();
    stage.showDefaultContextMenu=false;
    // declaring sharedObject
    var userInf:SharedObject = SharedObject.getLocal("userInformation", "/");
    if(userInf.data.userName != undefined) {
    gotoAndStop("closing");
    // saving data
    inf_bt.addEventListener(MouseEvent.CLICK, saveData);
    function saveData(evt:MouseEvent): void
    userInf.data.userName = input_name.text;
    userInf.data.userDate = input_date.text;
    userInf.data.userAge = input_age.text;
    gotoAndStop("pg1");
    // QUESTIONS  -- 25
    // CLOSING
    out_score.text = i.toString();
    userInf.data.userScore = out_score.text;
    trace("out_score.text is " +out_score.text);
    input_name.text =userInf.data.userName;
    input_date.text = userInf.data.userDate;
    input_age.text = userInf.data.userAge;
    save_bt.addEventListener(MouseEvent.CLICK, gotoResults);
    function gotoResults(evt:MouseEvent): void
    userInf.flush();
    gotoAndStop("intro");
    // clearing data
    reset_bt.addEventListener(MouseEvent.CLICK, deleteInf);
    function deleteInf(evt:MouseEvent): void
    userInf.clear();
    gotoAndStop("intro");
    For your help!
    German

  • Midlet not running on actual mobile phone

    hi,
    i made a small mdilet game its running fine on sun tool kit 2.5. but when i try to run it on any mobile phone the mobile phone becomse blank and dont shows anything. im using Nokia 6630,6280 and sony erricson K800i.
    please help me asap....

    actually im trying to make some sort of bluetooth chess game. i used Tiled Layer class to make the background (chess board) then i put imgaes on that chess board which i created with TiledLayer.
    the problem is this that when i made only TiledLayer and displayed it on the midlet it worked fine on all phones but when i pute images on top of that TiledLayer then mobile phones dont show anything not even the chess board
    heres the code...
    import javax.microedition.lcdui.*;
    import javax.microedition.lcdui.Graphics;
    import javax.microedition.lcdui.game.GameCanvas;
    import javax.microedition.lcdui.game.TiledLayer;
    public class GameScreen extends GameCanvas implements CommandListener, Runnable {
      // make ImageSet object
      private ImageSet imageSet;
      // instance of Graphics object
      private Graphics g;
      // the game boundary
      public static final int GAME_WIDTH = 160;
      public static final int GAME_HEIGHT = 160;
      // board block size
      public static final int BLOCK_X = 18;
      public static final int BLOCK_Y = 19;
      public static final int B_H_X = 3;
      public static final int B_H_Y = 1;
      // the new x,y origin of the game
      public final int GAME_START_X = (getWidth() - GAME_WIDTH)/2;
      public final int GAME_START_Y = (getHeight() - GAME_HEIGHT)/2;
      // the end x,y positions of the game
      public final int GAME_END_X = 18 * 8 ;
      public final int GAME_END_Y = 19 * 8 ;
      // block size of elements
      public final int BLOCK_SIZE_X = 18;
      public final int BLOCK_SIZE_Y = 19;
      // anchor for the golden ones
      public static final int GRAPHICS_TOP_RIGHT = Graphics.TOP | Graphics.RIGHT;
      // anchor for the blue ones
      public static final int GRAPHICS_VCENTER_RIGHT = Graphics.VCENTER | Graphics.RIGHT;
      // golden elements location the chess Image
      private final int goldElmtInImg[] = {0,8,3,4,7,2,9,0};
      // blue elements location the chess Image
      int blueElmtInImg[] = {0,9,2,5,6,3,8,1};
      // these are the images which we will get from ImageSet class
      private Image goldens[];
      private Image blues[];
      // these two images are gray and white area of the chess board
      //0 = white
      //1 = gray
      private Image chkImg[];
      public GameScreen() {
        super(true);
        try {
          jbInit();
        catch(Exception e) {
          e.printStackTrace();
      private void jbInit() throws Exception {
        g = getGraphics();
        chkImg = new Image[2];
        //create a new ImageSet
        imageSet = new ImageSet();
        // Set up this Displayable to listen to command events
        setCommandListener(this);
        // add the Exit command
        addCommand(new Command("Exit", Command.EXIT, 1));
        try {
          // makes chess Images
          imageSet.makeImages();
          drawImages(g);
        }catch(Exception e){
           e.printStackTrace();
       * The main GAME LOOP which goes infinity untill cancelled by the user
      public void run(){
       * Draws the images on the screen on specific locations
       * @param g Graphics: used to draw images on the board.
      public void drawImages(Graphics g){ 
        boolean flag = false;
        chkImg = imageSet.makeChkBox();   
        // paint the cheass board on the screen
        imageSet.createChessBoard(GAME_START_X,GAME_START_Y).paint(g);
        // set color to black and draw a rectangle around the chess board.
        g.setColor(0x000000);
        g.drawRect(GAME_START_X,GAME_START_Y,GAME_END_X,GAME_END_Y);
        goldens = imageSet.getGoldens();
        blues = imageSet.getBlues();
        // setting the color to green.
        g.setColor(0,255,0);
        g.drawRect(GAME_START_X+BLOCK_SIZE_X*4,GAME_START_Y+BLOCK_SIZE_Y*5, (GAME_START_X+BLOCK_SIZE_X*4)+BLOCK_SIZE_X,
                                                                         (GAME_START_Y+BLOCK_SIZE_Y*5)+BLOCK_SIZE_Y);
        System.out.println(GAME_START_X+BLOCK_SIZE_X*4+BLOCK_SIZE_X+"      "+GAME_START_Y+BLOCK_SIZE_Y*5+BLOCK_SIZE_Y);
        // drawing golden and blue elements
        g.drawImage(goldens[1],GAME_START_X+B_H_X,GAME_START_Y+B_H_Y,Graphics.TOP|Graphics.LEFT);
        g.drawImage(goldens[10],GAME_START_X+B_H_X,GAME_START_Y+BLOCK_Y+B_H_Y,Graphics.TOP|Graphics.LEFT);
        g.drawImage(blues[0],GAME_START_X+B_H_X,GAME_START_Y+BLOCK_Y*7+B_H_Y,Graphics.TOP|Graphics.LEFT);
        g.drawImage(blues[11],GAME_START_X+B_H_X,GAME_START_Y+BLOCK_Y*6+B_H_Y,Graphics.TOP|Graphics.LEFT);
        for (int i =1; i<=7; i++){ 
          g.drawImage(goldens[goldElmtInImg],GAME_START_X+BLOCK_X*i,
    GAME_START_Y+B_H_Y,Graphics.TOP|Graphics.LEFT);
    g.drawImage(blues[blueElmtInImg[i]],GAME_START_X+BLOCK_X*i,
    GAME_START_Y+BLOCK_Y*7+B_H_Y,Graphics.TOP|Graphics.LEFT);
    if(flag==true){
    g.drawImage(goldens[10],GAME_START_X+BLOCK_X * i +B_H_X ,
    GAME_START_Y+BLOCK_Y+B_H_Y,Graphics.TOP|Graphics.LEFT);
    g.drawImage(blues[11], GAME_START_X BLOCK_X * i B_H_X,
    GAME_START_Y + BLOCK_Y * 6 +B_H_Y,Graphics.TOP | Graphics.LEFT);       
    flag = false;
    else{
    g.drawImage(goldens[11],GAME_START_X+BLOCK_X * i +B_H_X ,
    GAME_START_Y+BLOCK_Y+B_H_Y,Graphics.TOP|Graphics.LEFT);
    g.drawImage(blues[10], GAME_START_X BLOCK_X * i B_H_X,
    GAME_START_Y + BLOCK_Y * 6 + B_H_Y,Graphics.TOP | Graphics.LEFT);
    flag = true;
    public void commandAction(Command command, Displayable displayable) {
    /** @todo Add command handling code */
    if (command.getCommandType() == Command.EXIT) {
    // stop the MIDlet
    ChessProject.quitApp();
    the helping class ImageSet which extracts the images from rerource file and manipulates them
    import javax.microedition.lcdui.*;
    import javax.microedition.lcdui.Graphics;
    import javax.microedition.lcdui.game.GameCanvas;
    import javax.microedition.lcdui.game.TiledLayer;
    public class ImageSet {
        // create a 2d array to store coordinates of images and their size
        // 1. size x
        // 2. size y
        // 3. location on the PNG
        private final int elements[][] = {{13,15,15},   // Gray Rock
                                         {13,15,28},   // White Rock
                                         {16,16,46},   // Gray Bishop
                                         {16,16,63},   // White Bishop
                                         {18,17,81},   // Gray Queen
                                         {18,17,99},   // White Queen
                                         {17,17,116},  // Gray King
                                         {17,17,133},  // White King
                                         {16,16,149},  // Gray Knight
                                         {16,16,167},  // White Knight
                                         {13,17,181},  // Gray Pawn
                                         {13,17,194}   // White Pawn
        private final int CELLS[] = {
                                    2, 1, 2, 1, 2, 1, 2, 1,
                                    1, 2, 1, 2, 1, 2, 1, 2,
                                    2, 1, 2, 1, 2, 1, 2, 1,
                                    1, 2, 1, 2, 1, 2, 1, 2,
                                    2, 1, 2, 1, 2, 1, 2, 1,
                                    1, 2, 1, 2, 1, 2, 1, 2,
                                    2, 1, 2, 1, 2, 1, 2, 1,
                                    1, 2, 1, 2, 1, 2, 1, 2
      // anchor for the golden ones
      public static final int GRAPHICS_TOP_RIGHT = Graphics.TOP | Graphics.RIGHT;
      // anchor for the blue ones
      public static final int GRAPHICS_VCENTER_RIGHT = Graphics.VCENTER | Graphics.RIGHT;
      // array of images others
      private Image allImagesOne[];
      // array of images mine
      private Image allImagesTwo[]; 
      public Image chessImg;
      // image to make the chess board
      private Image backgrndImg; 
      // to create the chess board
      private TiledLayer background; 
      private Image chkImg[] = new Image[2];
       * construction for initializing values
      public ImageSet() {
        allImagesOne = new Image[12];
        allImagesTwo = new Image[12];
        try{
          chessImg = Image.createImage("/chess.png");
          backgrndImg = Image.createImage("/board.png");     
        }catch(Exception e){
          e.printStackTrace();
       * This method creates the chess board and returns it to the calling code
       * @param GAME_START_X int: start position of game x axis
       * @param GAME_START_Y int: start position of game y axis
       * @return TiledLayer: the TiledLayer object returned
      public TiledLayer createChessBoard(int GAME_START_X, int GAME_START_Y){
        //create TiledLayer of image
        background = new TiledLayer(8, 8, backgrndImg,18 ,19);
        for (int i =0; i<CELLS.length; i++){
          int column = i % 8;
          int row = (i - column)/8;
          background.setCell(column, row, CELLS);
    System.out.println(GAME_START_X+" "+GAME_START_Y);
    background.setPosition(GAME_START_X,GAME_START_Y);
    return background;
    * this method creates two check boxes of board.png and returns to calling program
    * @return Image[]
    public Image[] makeChkBox(){
    chkImg[0] = Image.createImage(18,19);
    chkImg[1] = Image.createImage(18,19);
    chkImg[0].getGraphics().drawImage(backgrndImg, 18,0,GRAPHICS_TOP_RIGHT); // gray area
    chkImg[1].getGraphics().drawImage(backgrndImg, 37,0,GRAPHICS_TOP_RIGHT); // white area
    return chkImg;
    * Make the images of chess game and fill them in 2 arrays of the users one and two.
    public void makeImages() throws Exception{
    int tempVar =0;
    // get golden images
    for (int j = 0; j < 12; j++) {
    allImagesOne[j] = Image.createImage(elements[j][tempVar],
    elements[tempVar][++tempVar]);
    allImagesOne[j].getGraphics().drawImage(chessImg, elements[j][++tempVar], 0,
    GRAPHICS_TOP_RIGHT);
    tempVar-=2;
    setGoldens(allImagesOne);
    // get the blue images
    for (int j = 0; j<12; j++){
    allImagesTwo[j] = Image.createImage(elements[j][tempVar],
    elements[tempVar][++tempVar]);
    allImagesTwo[j].getGraphics().drawImage(chessImg,
    elements[j][++tempVar], 0,
    GRAPHICS_VCENTER_RIGHT);
    tempVar-=2;
    public void setGoldens (Image allImagesOne[]){
    this.allImagesOne = allImagesOne;
    public void setBlues(Image allImagesTwo[]){
    this.allImagesTwo = allImagesTwo;
    public Image[] getGoldens (){
    return this.allImagesOne;
    public Image[] getBlues (){
    return this.allImagesTwo;

Maybe you are looking for

  • JDev 10.1.3 - running any application results in connection pool error

    After creating a new project with a MySQL connection and since removing the project, I receive this error no matter which application I try to run through the local OC4J of JDev 10.1.3.0.4.3673. I can recreate this issue with a brand new app workspac

  • How to copy and use the RAID files for ATI SB600 for a new build

    WinXP Home MSI K9A Platinum AMD Athlon X2-3600+ 2 x Seagate 250GB SATA2 3GB/s HHD 2 x HIS X1950Pro in Crossfire 2 x OCZ2A8002GK Crossfire certified modules Enermax Galaxy 850 Hello, I plan on setting this new build up with SATA RAID 0. I tried to fol

  • Voice Control - does it learn and what's the "Wrong" command for?

    1) Like others, I find Voice Control laughably inaccurate sometimes when trying to get it to play an artist. I'm wondering if it "learns" and gets better the more you use it? 2) In the manual, there's a command you can called "wrong" or "nope". In wh

  • Can't Open Logic Pro

    I am running Logic Pro with 10.6, and after downloading firmware for  Digitech piece, I was directed to a security page and promted to download this code resources security patch.Now I cannot open Logic Pro I was promted to download this code resourc

  • IPhone SDK: How to have application files not be backed up by iTunes?

    We are writing a set of files to the tmp directory on the device, with the expectation that iTunes will not back it up. However, we are seeing that those files are backed up on the host computer. The following documentation: http://developer.apple.co