Can someone tell me what's wrong with this code....

I apologize in advance for anyone who isn't a Steelers fan...
import java.awt.*;
import javax.swing.*;
public class myJPanel extends JPanel
     public myJPanel()
          setBackground(Color.white);
     JLabel label1 = new JLabel();
     label1.setText("Ben Roethlisberger #7 Age 23");
     add(label1);
     JButton jb1;
     ImageIcon imageBen = new ImageIcon("Ben.JPG");
     jb1 = new JButton(imageBen);
     add(jb1);
     JLabel label3 = new JLabel();
     label3.setText(whatIsUp());
     add(label3);
     for(i=0;i<20;i++)
     String whatIsUp()
          int n = 0;
          double nn = 0;
          String b = "......";
          nn = (Math.random() * 6);
          n = (int)nn;
          if (n == 0)
               b = "Ben Roethlisberger throws a touchdown pass to Hines Ward.";
               JButton jb2;
          ImageIcon imageHines = new ImageIcon("Hines.jpg");
          jb2 = new JButton(imageHines);
          add(jb2);
          if (n == 1) b = "Ben Roethlisberger throws a touchdown pass to Antwaan Randle El.";
          if (n == 2) b = "Ben Roethlisberger throws a touchdown pass to Heath Miller.";
          if (n == 3) b = "Ben Roethlisberger throws a touchdown pass to Cedrick Wilson.";
          if (n == 4) b = "Ben Roethlisberger throws a touchdown pass to Jerame Tuman.";
          if (n == 5) b = "Ben Roethlisberger hands off to Jerome Bettis for a touchdown.";
          return b;
Everything is ok if i take the for loop out, but for some reason everything just gets screwed up if I have that for loop in there. And these are the error messages I'm getting.
'illegal start of type (line 21)' and '<identifier> expected (line 48)'
Thanks in advance for your help...

Hey I'm sorry but this is only my second week doing
Java. Do you think you could explain that more or
give me an example??
Bad Version (like yours but simplified)
public class Sample{
  public static void main(String args[]){
    for(int i=0;i<20;i++){
      String whatIsUp(){
         return "Doc";
      System.out.println(?);// I am not even sure how to write this voodoo part
}Good Version
public class Sample{
  public static void main(String args[]){
    for(int i=0;i<20;i++){
      String aString = whatIsUp();
      System.out.println(aString);
  String whatIsUp(){
    return "Doc";
}

Similar Messages

  • Can someone tell me what's wrong with this LOV query please?

    This query works fine..
    select FILTER_NAME display_value, FILTER_ID return_value
    from OTMGUI_FILTER where username = 'ADAM'
    But this one..
    select FILTER_NAME display_value, FILTER_ID return_value
    from OTMGUI_FILTER where username = apex_application.g_user
    Gives the following error.
    1 error has occurred
    * LOV query is invalid, a display and a return value are needed, the column names need to be different. If your query contains an in-line query, the first FROM clause in the SQL statement must not belong to the in-line query.
    Thanks very much,
    -Adam vonNieda

    Ya know, I still don't know what's wrong with this.
    declare
    l_val varchar2(100) := nvl(apex_application.g_user,'ADAM');
    begin
    return 'select filter_name display_value, filter_id return_value
    from otmgui_filter where username = '''|| l_val || '''';
    end;
    Gets the same error as above. All I'm trying to do is create a dropdown LOV which selects based on the apex_application.g_user.
    What am I missing here?
    Thanks,
    -Adam

  • Can someone tell me what's wrong with this method

    public boolean drop(int col, int piece) {
              if (isLegalMove(col)) {
                   for (int r = 0; r < getNumRows(); r++) {
                        if (mySpaces[r][col] == EMPTY) {
                             mySpaces[r][col] = piece;
                             return true;
              } else
                   return false;
         }it always asks that I need to return something, what should I do??

    public boolean drop(int col, int piece) {
        if (isLegalMove(col)) {
            for (int r = 0; r < getNumRows(); r++) {
              if (mySpaces[r][col] == EMPTY) {
                mySpaces[r][col] = piece;
                return true;
        } //else <--- remove the else
        return false;
    }

  • Please can someone tell me what's wrong in this code

    1var a=0;
    2function main(){
    3var inFolder = Folder.selectDialog("Please select folder to process");
    4//Save the Current Preferences
    5var startRulerUnits = preferences.rulerUnits;
    6preferences.rulerUnits = Units.PIXELS;
    7//Get all the files in the folder
    8var filelist=inFolder.getFiles()
    9n=filelist.length;
    10//Open each file
    11for(a=0; a<n; a++){
    12// The fileList is folders and files so open only files
    13if (fileList[a] instanceof File) {
    14open(fileList[i])
    15var docName = app.activeDocument.name;
    16app.activeDocument.flatten();
    17activedocument.save();
    18}
    19}
    20}
    21main();
    Says the error is "filelist is not recognized".    on line 14.   I thought I had fully defined 'filelist' on line8
    I thought filelist was a one-D array variable.
    Peterkal

    Also, in lines 8 and 9 you use a variable called "filelist" but in lines 13 and 14 you call it "fileList" (notice the capital-L).
    JavaScript is case-sensitive, so you must be consistent with your variable names throughout.

  • I can't figure out what's wrong with this code

    First i want this program to allow me to enter a number with the EasyReader class and depending on the number entered it will show that specific line of this peom:
    One two buckle your shoe
    Three four shut the door
    Five six pick up sticks
    Seven eight lay them straight
    Nine ten this is the end.
    The error message i got was an illegal start of expression. I can't figure out why it is giving me this error because i have if (n = 1) || (n = 2) statements. My code is:
    public class PoemSeventeen
    public static void main(String[] args)
    EasyReader console = new EasyReader();
    System.out.println("Enter a number for the poem (0 to quit): ");
    int n = console.readInt();
    if (n = 1) || (n = 2)
    System.out.println("One, two, buckle your shoe");
    else if (n = 3) || (n = 4)
    System.out.println("Three, four, shut the door");
    else if (n = 5) || (n = 6)
    System.out.println("Five, six, pick up sticks");
    else if (n = 7) || (n = 8)
    System.out.println("Seven, eight, lay them straight");
    else if (n = 9) || (n = 10)
    System.out.println("Nine, ten, this is the end");
    else if (n = 0)
    System.out.println("You may exit now");
    else
    System.out.println("Put in a number between 0 and 10");
    I messed around with a few other thing because i had some weird errors before but now i have narrowed it down to just this 1 error.
    The EasyReader class code:
    // package com.skylit.io;
    import java.io.*;
    * @author Gary Litvin
    * @version 1.2, 5/30/02
    * Written as part of
    * <i>Java Methods: An Introduction to Object-Oriented Programming</i>
    * (Skylight Publishing 2001, ISBN 0-9654853-7-4)
    * and
    * <i>Java Methods AB: Data Structures</i>
    * (Skylight Publishing 2003, ISBN 0-9654853-1-5)
    * EasyReader provides simple methods for reading the console and
    * for opening and reading text files. All exceptions are handled
    * inside the class and are hidden from the user.
    * <xmp>
    * Example:
    * =======
    * EasyReader console = new EasyReader();
    * System.out.print("Enter input file name: ");
    * String fileName = console.readLine();
    * EasyReader inFile = new EasyReader(fileName);
    * if (inFile.bad())
    * System.err.println("Can't open " + fileName);
    * System.exit(1);
    * String firstLine = inFile.readLine();
    * if (!inFile.eof()) // or: if (firstLine != null)
    * System.out.println("The first line is : " + firstLine);
    * System.out.print("Enter the maximum number of integers to read: ");
    * int maxCount = console.readInt();
    * int k, count = 0;
    * while (count < maxCount && !inFile.eof())
    * k = inFile.readInt();
    * if (!inFile.eof())
    * // process or store this number
    * count++;
    * inFile.close(); // optional
    * System.out.println(count + " numbers read");
    * </xmp>
    public class EasyReader
    protected String myFileName;
    protected BufferedReader myInFile;
    protected int myErrorFlags = 0;
    protected static final int OPENERROR = 0x0001;
    protected static final int CLOSEERROR = 0x0002;
    protected static final int READERROR = 0x0004;
    protected static final int EOF = 0x0100;
    * Constructor. Prepares console (System.in) for reading
    public EasyReader()
    myFileName = null;
    myErrorFlags = 0;
    myInFile = new BufferedReader(
    new InputStreamReader(System.in), 128);
    * Constructor. opens a file for reading
    * @param fileName the name or pathname of the file
    public EasyReader(String fileName)
    myFileName = fileName;
    myErrorFlags = 0;
    try
    myInFile = new BufferedReader(new FileReader(fileName), 1024);
    catch (FileNotFoundException e)
    myErrorFlags |= OPENERROR;
    myFileName = null;
    * Closes the file
    public void close()
    if (myFileName == null)
    return;
    try
    myInFile.close();
    catch (IOException e)
    System.err.println("Error closing " + myFileName + "\n");
    myErrorFlags |= CLOSEERROR;
    * Checks the status of the file
    * @return true if en error occurred opening or reading the file,
    * false otherwise
    public boolean bad()
    return myErrorFlags != 0;
    * Checks the EOF status of the file
    * @return true if EOF was encountered in the previous read
    * operation, false otherwise
    public boolean eof()
    return (myErrorFlags & EOF) != 0;
    private boolean ready() throws IOException
    return myFileName == null || myInFile.ready();
    * Reads the next character from a file (any character including
    * a space or a newline character).
    * @return character read or <code>null</code> character
    * (Unicode 0) if trying to read beyond the EOF
    public char readChar()
    char ch = '\u0000';
    try
    if (ready())
    ch = (char)myInFile.read();
    catch (IOException e)
    if (myFileName != null)
    System.err.println("Error reading " + myFileName + "\n");
    myErrorFlags |= READERROR;
    if (ch == '\u0000')
    myErrorFlags |= EOF;
    return ch;
    * Reads from the current position in the file up to and including
    * the next newline character. The newline character is thrown away
    * @return the read string (excluding the newline character) or
    * null if trying to read beyond the EOF
    public String readLine()
    String s = null;
    try
    s = myInFile.readLine();
    catch (IOException e)
    if (myFileName != null)
    System.err.println("Error reading " + myFileName + "\n");
    myErrorFlags |= READERROR;
    if (s == null)
    myErrorFlags |= EOF;
    return s;
    * Skips whitespace and reads the next word (a string of consecutive
    * non-whitespace characters (up to but excluding the next space,
    * newline, etc.)
    * @return the read string or null if trying to read beyond the EOF
    public String readWord()
    StringBuffer buffer = new StringBuffer(128);
    char ch = ' ';
    int count = 0;
    String s = null;
    try
    while (ready() && Character.isWhitespace(ch))
    ch = (char)myInFile.read();
    while (ready() && !Character.isWhitespace(ch))
    count++;
    buffer.append(ch);
    myInFile.mark(1);
    ch = (char)myInFile.read();
    if (count > 0)
    myInFile.reset();
    s = buffer.toString();
    else
    myErrorFlags |= EOF;
    catch (IOException e)
    if (myFileName != null)
    System.err.println("Error reading " + myFileName + "\n");
    myErrorFlags |= READERROR;
    return s;
    * Reads the next integer (without validating its format)
    * @return the integer read or 0 if trying to read beyond the EOF
    public int readInt()
    String s = readWord();
    if (s != null)
    return Integer.parseInt(s);
    else
    return 0;
    * Reads the next double (without validating its format)
    * @return the number read or 0 if trying to read beyond the EOF
    public double readDouble()
    String s = readWord();
    if (s != null)
    return Double.parseDouble(s);
    // in Java 1, use: return Double.valueOf(s).doubleValue();
    else
    return 0.0;
    Can anybody please tell me what's wrong with this code? Thanks

    String[] message = {
        "One, two, buckle your shoe",
        "One, two, buckle your shoe",
        "Three, four, shut the door",
        "Three, four, shut the door",
        "Five, six, pick up sticks",
        "Five, six, pick up sticks",
        "Seven, eight, lay them straight",
        "Seven, eight, lay them straight",
        "Nine, ten, this is the end",
        "Nine, ten, this is the end"
    if(n>0)
        System.out.println(message[n]);
    else
        System.exit(0);

  • Can someone tell me what's wrong with my router?

    i was just using my router half-hour ago and it was working fine......i come back on a little bit and it is not working anymore........my wlan and dmz light in front of my WRT54G router won't light up and it keeps telling me that my connection is limited...i already reset both router and cable modems like 100 times already..is there any way i could fix this?

    okay...  if you are using cable internet connection, try restting the router back to factory default settings by pressing reset butoon on the back panel of router, power cycle the n/w by unplugging power cable of router and modem, wait for couple of minutes and power up the modem first once modem is rebooted power up the router, check internet works or not, if still doesn't work let me know which internet service are you using also tell me version no of WRT54G router so that i can tell you step by step configuration of router...

  • Can someone tell me what's wrong with my threading code

    I got some code from a Java book on how to create a simple threading application. This is the exact code from the book but for some reason it gives me an error that non-static variables can not be referenced from static content. How can I reword this to work?
    <CODE>
    package multithread;
    import java.io.*;
    import java.util.*;
    public class MultiThread {
    class CountDownEven extends Thread {
    public void run() {
    for (int i = 6; i > 0; i -= 2) {
    System.out.println(this.getName() + " Count" + i);
    Thread.yield();
    class CountDownOdd extends Thread {
    public void run() {
    for (int i = 5; i > 0; i -= 2) {
    Thread.yield();
    public static void main(String[] args) {
    try {
    CountDownEven count1 = new CountDownEven();
    CountDownOdd count2 = new CountDownOdd();
    count1.start();
    count2.start();
    catch (Exception e)
    </CODE>

    One possible solution:public static void main(String[] args) {
         try {
              MultiThread m = new MultiThread();
              CountDownEven count1 = m.new CountDownEven();
              CountDownOdd count2 = m.new CountDownOdd();
              count1.start();
              count2.start();
         } catch (Exception e) {
    }

  • Can someone tell me i did wrong with this part of my code?

    choice = Integer.parseInt (usersChoice);//Math Conversion
         Input = JOptionPane.showInputDialog(null, "How many would you like?[" + Quantity +"]: ");
         price[Quantity] = Float.parseFloat(Input);//conversion from string to int
    JOptionPane.showMessageDialog(null, "You want: " + price[Quantity]);
    for (Quantity=0; Quantity<100;Quantity++)
    When i try to compile i am getting an error "incompatible types" and operator > and ++ cannot be applied to int[],int and int[]

    When i ask a question of my instructor i am lucky if i get a response 48 hrs later, and as for asking my peers, most of them are just as confused as i am. All i am doing is trying to learn i am sorry if you feel that asking on this forum is wrong, but like i said i am attemtping to learn and i figured that who better than to ask then a bunch of people who know Java like the back of their hands.

  • Please, someone tell me what's wrong in this code...

    My MIDlet can't even start. So I think the problem is on GameCanvas class, 'couse is the only class I've changed before the game don't work. So I'll submit the code and you can see if find the error. Any sugestions will be apreciate.
    import javax.microedition.lcdui.*;
    import javax.microedition.lcdui.game.*;
    public class GameCanvasClass extends GameCanvas implements Runnable {
       private boolean playing;  
       // TiledLayer.
       private TiledLayer tiledCenary;
       // Layer.
       private LayerManager layer1 = new LayerManager();
       // Sprites.
       private CharacterClass player;
       private CharacterClass[] enemy;
       // Game settings;
       public static int gameLevel = 0;
       public static int numLives = 3;
       public static int numEnemies = 0;
       public static final int NUMBER_LEVELS = 10;
       public static boolean[] doneBuildLevel;
       /** Creates a new instance of GameCanvasClass */
       public GameCanvasClass() throws Exception {
          super(true);
          for(int i = 0; i < 10; i++)
             doneBuildLevel[i] = false;   
          Image image = Image.createImage("/bear.PNG");
          player = new CharacterClass(image, 16, 16, 16, 16);
          System.out.println("Public constructor started.");
       public void start() throws Exception {
          playing = true;
          Thread t = new Thread(this);
          t.start();
          System.out.println("start() method of Thread is on.");
       public void run() {
            try {
               setupGameLevel(gameLevel);
            catch(Exception e) {
               e.printStackTrace();
          Graphics g = getGraphics();
          while(playing == true) {
             drawGameScreen(g);
             checkCollision(numEnemies);
             checkInput();
             moveEnemies(numEnemies);
             try {
                Thread.sleep(15);
             catch(InterruptedException ie) {
       public void stop() {
          playing = false;      
       private void setupGameLevel(int level) throws Exception {
          if( (level == 0) && (doneBuildLevel[level] == false) ) {
             // Building cenary for the first level.
             tiledCenary = TiledLayerClass.buildTiledCenary(gameLevel);
             // Append to the layer.
             layer1.append(tiledCenary);
             layer1.append(player);
             doneBuildLevel[level] = true;
             numEnemies = 4;   // Setup 4 enemies for the first level.
             for(int i = 0; i < numEnemies; i++) {
                Image imagem = Image.createImage("/enemy1.PNG");  
                enemy[i] = new CharacterClass(imagem, 16, 16, 160, 32);
                layer1.append(enemy);
    /* TODO
    Change manually positions of all enemies,
    since they start at the same position.
    private void checkInput() {
    int keyState = getKeyStates();
    if(((keyState & UP_PRESSED) != 0) && (player.getPosY() > 16)) {
    player.setLastPosY(player.getPosY());
    player.setPosY(player.getPosY() - 1);
    if(((keyState & DOWN_PRESSED) != 0) && (player.getPosY() < 208)) {
    player.setLastPosY(player.getPosY());
    player.setPosY(player.getPosY() + 1);
    if(((keyState & RIGHT_PRESSED) != 0) && (player.getPosX() < 208)) {
    player.setLastPosX(player.getPosX());
    player.setPosX(player.getPosX() + 1);
    if(((keyState & LEFT_PRESSED) != 0) && (player.getPosX() > 16)) {
    player.setLastPosX(player.getPosX());
    player.setPosX(player.getPosX() - 1);
    /* Check collision of player against cenary, enemies, itens. Also check collision of all enemies against cenary.
    Method must receive the number of enemies on the current level. */
    private void checkCollision(int numberEnemies) {
    if(player.collidesWith(tiledCenary, true)) {
    player.setPosX(player.getLastPosX());
    player.setPosY(player.getLastPosY());
    for(int i = 0; i < numberEnemies; i++)
    if(enemy[i].collidesWith(tiledCenary, true)) {
    enemy[i].setPosX(enemy[i].getLastPosX());
    enemy[i].setPosY(enemy[i].getLastPosY());
    private void moveEnemies(int numberEnemies) {
    for(int i = 0; i < numberEnemies; i++) {
    if(enemy[i].getPosX() < 208) {
    enemy[i].setLastPosX(enemy[i].getPosX());
    enemy[i].setPosX(enemy[i].getPosX() + 1);
    if(enemy[i].getPosX() > 16) {
    enemy[i].setLastPosX(enemy[i].getPosX());
    enemy[i].setPosX(enemy[i].getPosX() - 1);
    private void drawGameScreen(Graphics g) {
    g.fillRect(0, 0, 256, 256);
    player.setPosition(player.getPosX(), player.getPosY());
    for(int i = 0; i < numEnemies; i++)
    enemy[i].setPosition(enemy[i].getPosX(), enemy[i].getPosY());
    layer1.setViewWindow(player.getPosX() - 32, player.getPosY() - 32, 128, 110);
    layer1.paint(g, 0, 0);
    g.setColor(0, 0, 0);
    flushGraphics();

    Hi,
    One thing that stroke me when I read your code is that you never allocate arrays
    replace
    private CharacterClass[] enemy;by
    private CharacterClass[] enemy = new CharacterClass[MAX_ENEMIES];and
    public static boolean[] doneBuildLevel;by
    public static boolean[] doneBuildLevel = new boolean[NUMBER_LEVELS];Hope that help,
    Jack

  • Could you tell me what is wrong with this code?

    import java.io.*;
    import java.lang.String;
    import java.util.*;
    import java.util.Properties;
    import java.io.InputStream;
    public class EStoreClient2 {
    private void insertTable (Vector value) {
         insertStmnt.setString(1, (String)value.get(0)
    public void static main (String args[]) {
         Vector argument = new Vector();
         if (args.length > 0) {
              for (int i=1; i < args.length; i++) {
                   argument.add(args);
                   System.out.println("<argument[]> = " + args[i]);
              EStoreClient2 estore = new EStoreClient2();
              if (args[0].equalsIgnoreCase("-insertitem"))
              estore.insertTable(argument);
    but it gives me
    EStoreClient2.java:18: Method get(int) not found in class
    java.util.Vector.
    insertStmnt.setString(1, (String)value.get(0));

    EStoreClient2.java:18: Method get(int) not found in
    class
    java.util.Vector.
    insertStmnt.setString(1,
    nsertStmnt.setString(1, (String)value.get(0));The method get(int) was introduced into the Vector class starting at JDK1.2. You must be using an earlier version of the JDK.

  • What is wrong with this code? on(release) gotoAndPlay("2")'{'

    Please could someone tell me what is wrong with this code - on(release)
    gotoAndPlay("2")'{'
    this is the error that comes up and i have tried changing it but it is not working
    **Error** Scene=Scene 1, layer=Layer 2, frame=1:Line 2: '{' expected
         gotoAndPlay("2")'{'
    Total ActionScript Errors: 1 Reported Errors: 1
    Thanks

    If you have a frame labelled "2" then it should be:
    on (release) {
        this._parent.gotoAndPlay("2");
    or other wise just the following to go to frame 2:
    on (release) {
         this._parent.gotoAndPlay(2);
    You just had a missing curly bracket...

  • I have i pad 2 ios 4.3.1 i want to update it to 4.3.3 but i get error msg 3194 can you tell me what's wrong with apple some people talking about apple don't veryfiy 4.3.3 anymore thanks alot

    i have i pad 2 ios 4.3.1 i want to update it to 4.3.3 but i get error msg 3194 can you tell me what's wrong with apple some people talking about apple don't veryfiy 4.3.3 anymore thanks alot

    4.3.5 is the current version, so that is the version that iTunes will download, not 4.3.3
    In terms of error 3194, have you got the latest version of iTunes on your computer ? - http://support.apple.com/kb/TS3694#error3194

  • What's wrong with this code (in recursion there may be a problem )

    // ELEMENTS OF TWO VECTORS ARE COMPARED HERE
    // CHECK WHAT IS WRONG WITH THIS PGM
    // there may be a problem in recursion
    import java.util.*;
    class Test
    Vector phy,db;
    public static void main(String adf[])
         Vector pp1=new Vector();
         Vector dp1=new Vector();
         //adding elements to the vector
         pp1.add("1");
         pp1.add("a");
         pp1.add("b");
         pp1.add("h");
         pp1.add("c");
         dp1.add("q");
         dp1.add("c");
         dp1.add("h");
         dp1.add("w");
         dp1.add("t");
         printVector(dp1);
         printVector(pp1);
         check2Vectors(pp1,dp1);
    public static void printVector(Vector v1)
         System.out.println("Vector size "+v1.size());
         for(int i=0;i<v1.size();i++)
              System.out.println(v1.get(i).toString());
    public static void check2Vectors(Vector p,Vector d)
         System.out.println("p.size() "+p.size()+" d.size() "+d.size());
         printVector(p);
         printVector(d);
         for(int i=0;i<p.size();i++)
                   for(int j=0;j<d.size();j++)
                        System.out.println(" i= "+i+" j= "+j);
                        Object s1=p.elementAt(i);
                        Object s2=d.elementAt(j);
              System.out.println("Checking "+s1+" and "+s2);
                        if(s1.equals(s2))
    System.out.println("Equal and Removing "+s1+" and "+s2);
                             p.remove(i);
                             d.remove(j);
                             printVector(p);
                             printVector(d);                    
                        check2Vectors(p,d);
                   }//inner for
              }//outer for     
    if(p.size()==0||d.size()==0)
    System.out.println("Vector checking finished and both match");
    else
    System.out.println("Vector checking finished and both do not match");
    }//method
    }

    hi,
    but the upper limit is changing everytime you call the function recursively
    so there should not be any problem(i suppose)
    my intension is to get the unmatched elements of the two vectors
    suggest me changes and thanks in advancce
    ashok
    The problems comes from the fact that you remove
    elements for a Vector while iterating in a loop where
    the upper limit as been set to the initial size of the
    Vector.
    You should use so while loops with flexible stop
    conditions that would work when the size of the Vector
    changes.
    Finally: why don't you use Vector.equals() ?

  • FB4 doesn't tell me what's wrong with my code. Not even letting me trace().

    Attached is my code that run well but the problem is, I know there is something wrong with my code since the dropdown list isn't populated unlike the textarea. Doesn't even put anything on the output panel when i do trace()-ing.
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
    xmlns:s="library://ns.adobe.com/flex/spark"
    xmlns:mx="library://ns.adobe.com/flex/halo"
    creationComplete="application1_initializeHandler(event)">
    <s:layout>
    <s:BasicLayout/>
    </s:layout>
    <fx:Script>
    <![CDATA[
    import mx.events.FlexEvent;
    protected function application1_initializeHandler(event:FlexEvent):void
    var xml:XML;
    var xmlLoader:URLLoader = new URLLoader();
    xmlLoader.load(new URLRequest('data/places.xml'));
    xmlLoader.addEventListener(
    Event.COMPLETE,
    function (e:Event):void {
    xml = new XML(e.target.data);
    trace(xml.place[0].barangay.descendants().toXMLString());
    for each (var pro:Object in xml.places.place)
    dp.dataProvider.addItem({province:pro.province});
    ta.text = xml.place[0].barangay.descendants().toXMLString();
    ]]>
    </fx:Script>
    <s:DropDownList id="dp"
    labelField="province"
    width="197"
    x="10" y="10"/>
    <s:TextArea x="198" y="186" id="ta" editable="true"/>
    </s:Application>

    @jdesko:
    i tried both with or w/o the nightly builds, still i can't see anything on the output panel using trace and the above code doesn't trigger the Error Panel why the dropdown list isn't populated..
    @Jason: thanks. the prob was with my e4x expression but with the console output thingy, now i run in debug mode but got the error:
    C:\Windows\System32\Macromed\Flash\NPSWF32.dll
    Flash Builder cannot locate the required debugger version of Adobe Flash Player. You might need to install the debugger version of the Flash Player or reinstall Flash Builder.
    Do you want to try to debug with the current version?
    I thought FB4 has this already in the package. I'm wondering why it asks for like this.

  • What's wrong with this code (AS3)?

    I want to publish a live stream and, when a button is pressed, publish the same stream for vod.  I haven't been able to get an answer as to whether I can do this...my code is below.  Can someone please tell me if I can do this, or what may be wrong with my code?
    The live stream and playback works fine; but the recording doesn't start.  Also, I want other objects on the client, such as the current camera and audio information, and the aspect ratio being used.  I havent' been able to get these to show up (i.e., the incomingLbl and outgoingLbl do not show up).
    Thank you,
    Phillip A
    My code:
    package {
        import flash.display.MovieClip;
        import flash.net.NetConnection;
        import flash.events.NetStatusEvent; 
        import flash.events.MouseEvent;
        import flash.events.AsyncErrorEvent;
        import flash.net.NetStream;
        import flash.media.Video;
        import flash.media.Camera;
        import flash.media.Microphone;
        import fl.controls.Button;
        import fl.controls.Label;
        import fl.controls.TextArea;
        import fl.controls.CheckBox;
        public class vodcast1 extends MovieClip {
            private var nc:NetConnection;
            private var nc2:NetConnection;
            private var ns:NetStream;
            private var ns2:NetStream;
            private var nsPlayer:NetStream;
            private var vid:Video;
            private var vidPlayer:Video;
            private var cam:Camera;
            private var mic:Microphone;
            private var camr:Camera;
            private var micr:Microphone;
            private var clearBtn:Button;
            private var startRecordBtn:Button;
            private var outgoingLbl:Label;
            private var incomingLbl:Label;
            private var myMetadata:Object;
            private var outputWindow:TextArea;
            private var cb1:CheckBox;
            public function vodcast1(){
                setupUI();
                nc = new NetConnection();
                nc.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
                nc.connect("rtmp://localhost/publishLive");
                nc2 = new NetConnection();
                nc2.connect("rtmp://localhost/vod/videos");
                nc2.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus2);
            private function startRecordHandler(event:MouseEvent):void {
                publishRecordStream();
            private function onNetStatus(event:NetStatusEvent):void {
                trace(event.target + ": " + event.info.code);
                switch (event.info.code)
                    case "NetConnection.Connect.Success":
                        trace("Congratulations! you're connected to live");
                        publishCamera();
                        displayPublishingVideo();
                        displayPlaybackVideo();
                        break;
                    case "NetStream.Publish.Start":
            // NetStatus handler for Record stream       
            private function onNetStatus2(event:NetStatusEvent):void {
                trace(event.target + ": " + event.info.code);
                switch (event.info.code)
                    case "NetConnection.Connect.Success":
                        trace("Congratulations! you're connected to vod");                   
                        break;
                    case "NetConnection.Connect.Rejected":
                    case "NetConnection.Connect.Failed":
                    trace ("Oops! the connection was rejected");
                        break;
                    case "NetStream.Publish.Start":
                        sendMetadata();
                        break;
            private function asyncErrorHandler(event:AsyncErrorEvent):void {
                trace(event.text);
            private function sendMetadata():void {
                trace("sendMetaData() called")
                myMetadata = new Object();
                myMetadata.customProp = "Recording in progress";
                ns.send("@setDataFrame", "onMetaData", myMetadata);
            private function publishRecordStream():void {
                camr = Camera.getCamera();
                micr = Microphone.getMicrophone();
                ns2 = new NetStream(nc2);
                ns2.client = new Object();
                ns2.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus2);
                ns2.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
                ns2.attachCamera(camr);
                ns2.attachAudio(micr);
                ns2.publish("vodstream", "record");           
            private function publishCamera():void {
                cam = Camera.getCamera();
                mic = Microphone.getMicrophone();
                ns = new NetStream(nc);
                ns.client = this;
                ns.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
                ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
                ns.attachCamera(cam);
                ns.attachAudio(mic);
                ns.publish("livestream", "live");
            private function displayPublishingVideo():void {
                vid = new Video(cam.width, cam.height);
                vid.x = 10;
                vid.y = 30;
                vid.attachCamera(cam);
                addChild(vid); 
            private function displayPlaybackVideo():void {
                nsPlayer = new NetStream(nc);
                nsPlayer.client = this;
                nsPlayer.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
                nsPlayer.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
                nsPlayer.play("livestream");
                vidPlayer = new Video(cam.width, cam.height);
                vidPlayer.x = cam.width + 100;
                vidPlayer.y = 30;
                vidPlayer.attachNetStream(nsPlayer);
                addChild(vidPlayer);
            private function setupUI():void {
                outputWindow = new TextArea();
                outputWindow.move(250, 175);
                outputWindow.width = 200;
                outputWindow.height = 50;
                outgoingLbl = new Label();
                incomingLbl = new Label();
                outgoingLbl.width = 100;
                incomingLbl.width = 100;
                outgoingLbl.text = "Publishing Stream";
                incomingLbl.text = "Playback Stream";
                outgoingLbl.move(20, 200);
                incomingLbl.move(300, 200);
                outgoingLbl.condenseWhite = true;
                incomingLbl.condenseWhite = true;
                startRecordBtn = new Button();
                startRecordBtn.width = 150;
                startRecordBtn.move(250, 345);
                startRecordBtn.label = "Start Recording";
                startRecordBtn.addEventListener(MouseEvent.CLICK, startRecordHandler);
                //cb1 = new CheckBox();
                //cb1.label = "Record";
                //cb1.move(135,300);
                //cb1.addEventListener(MouseEvent.CLICK,publishRecordStream);
                //clearBtn = new Button();
    //            clearBtn.width = 100;
    //            clearBtn.move(135,345);
    //            clearBtn.label = "Clear Metadata";
    //            clearBtn.addEventListener(MouseEvent.CLICK, clearHandler);
                addChild(outgoingLbl);
                addChild(incomingLbl);
    //            addChild(clearBtn);
                addChild(startRecordBtn);
    //            addChild(cb1);
                addChild(outputWindow);
            public function onMetaData(info:Object):void {
                outputWindow.appendText(info.customProp);

    use event.currentTarget (and you don't need to repeatedly define the same function):
    var c:int;
    var buttonName:String;
    for (c = 1;c < 5;c++) {
         buttonNum = "button"+c;
         this[buttonNum].addEventListener(MouseEvent.MOUSE_DOWN, pressStepButton);
    function pressStepButton(event:MouseEvent) {          trace(event.currentTarget,event.currentTarget.name);     }

Maybe you are looking for

  • Can't see photos in library

    Yesterday my computer offered me an update to iPhoto and said that the thumbnails needed to be upgraded (or something along those lines). I clicked yes, and then I think foolishly, imported some more photos whilst this was occuring (I assume. I didnt

  • Alv output issue

    Hi everyone,                   i m posting one of my ALV Program which i m having error as well as i m having few doubts , frnds plz clarify. <code> *ztest_alv_sri. *& Report  ZSrialv                                                 * REPORT  ZSrialv

  • Z400: Adjusting the Brightness in Windows 8.1

    For machine Z400/Z500 with and without touch as well as P500, this article will help for the issue with brightness control right after updating to Windows 8.1.

  • Unable to create follow-up document in Portal

    Hi, We are using NetWeaver Portal 7.0 and it is at the latest SP(SP10). When we are trying to create a follow-up document for an opportunity all the fields are getting grayed out and we are unable to create any follow-up document.But from GUI we are

  • Leopard on my macbook, will it run as well as tiger?

    i have a 1.83GHz intel core 2 duo macbook with 512 ram. can anyone tell me if upgrading to leopard when it comes out will make my mac run slower or would it even run faster? i am most worried i don't have enough ram to really support leopard.