Declare a variable typed "name of a class"-Need help

I have "segment" class in package named Ex13
import Exercise12.Point123;
public class segment {
     private Point123 start;
     private Point123 end;
     public segment(Point123 start, Point123 end) {
          this.start = start;
          this.end = end;
     public double length() {
          return start.distance(end.getX(), end.getY());
     public String midlePoint() {
          return (end.getX() + start.getX()) / 2 + " "
                    + (end.getY() + start.getY()) / 2;
          // return insidePoint(1,1);
     public Point123 insidePoint(double m, double n) {
          double ratio = m / (m + n);
          return new Point123(start.getX()+(end.getX() - start.getX()) * ratio,
                    start.getY()+(end.getY() - start.getY()) * ratio);
//return (start.getX()+(end.getX() - start.getX())*ratio);
}And class "Point123" in package Ex12:
public class Point123 {
     private double x;
     private double y;
     public Point123(double xAsis, double yAsis) {
          x = xAsis;
          y = yAsis;
     public double getX() {
          return x;
     public double getY() {
          return y;
//     public String toString() {
//          return String.format("%.1f,%.1f", x, y);
     public boolean isOrigin() {
          return x == 0 && y == 0;
     public boolean isOnX_Axis() {
          return y == 0;
     public boolean isOnY_Axis() {
          return x == 0;
     public double distance(double xAsis, double yAsis) {
          return Math.sqrt(Math.pow(xAsis - x, 2) + Math.pow(yAsis - y, 2));
}I remove toString method in Point123 class, but whenever I call insidePoint method in segment class it print out "Exercise12.Point123@addbf1". In other hand, I don't remove toString method, I call insidePoint method,then it prints out the correct result which I want.
I think the reason why this thing happened is that I am using Point123 return type in insidePoint method. To midlePoint method in segment class, it does not affect whether I remove toString or not. That is because I use its own String return type.
Can someone tells me whether my thought is correct or not? And explain more about variable typed "name of a class"

Oh! My header's segment class does not have extend...., therefore it inherit from the Object. But what is Object in my class?
is it "*s*" in my code?
public class DisplayResult {
     public static void main(String[] args) {
               segment s  = new segment(new Point123(3,4), new Point123(6,7));
               System.out.println(s.length());
               System.out.println(s.midlePoint());
               System.out.println(s.insidePoint(1.5,4));
}

Similar Messages

  • What is wrong with my variables....I really need help soon

    I need help. I know I need to add in repaint and change methods, but how come, when I put the starting values of my sliders for R: 0 G: 50 B: 0, the square is not green when it loads? IT is just black. What should happen, at least what I think[i] should happen, is that the rectangle would load green. And should the line:
    JPanel = new Rectglbe
    JPanel = new JPanel
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class Slider extends JFrame {
            int red, blue, green;
            public Slider() {
                    super("ColorChanger");
                    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                    //Info
                    String Run = "Running, Close Program For Prompt\n";
                    System.out.println(Run);
                    //Labels
                    JLabel RedLabel = new JLabel("                                             Red:");
                    JLabel GreenLabel = new JLabel("               Green:");
                    JLabel BlueLabel = new JLabel("               Blue:");
                    //Red Slider
                    JSlider pickR = new JSlider(JSlider.VERTICAL, 0, 255, 0);
                    pickR.setMajorTickSpacing(50);
                    pickR.setMinorTickSpacing(5);
                    pickR.setPaintTicks(true);
                    pickR.setPaintLabels(true);
                    //Green Slider
                    JSlider pickG = new JSlider(JSlider.VERTICAL, 0, 255, 50);
                    pickG.setMajorTickSpacing(50);
                    pickG.setMinorTickSpacing(5);
                    pickG.setPaintTicks(true);
                    pickG.setPaintLabels(true);
                    //Blue Slider
                    JSlider pickB = new JSlider(JSlider.VERTICAL, 0, 255, 0);
                    pickB.setMajorTickSpacing(50);
                    pickB.setMinorTickSpacing(5);
                    pickB.setPaintTicks(true);
                    pickB.setPaintLabels(true);
                    JPanel pane = new Rectgl();
                    pane.add(RedLabel);
                    pane.add(pickR);
                    pane.add(GreenLabel);
                    pane.add(pickG);
                    pane.add(BlueLabel);
                    pane.add(pickB);
                    setContentPane(pane);
                    public int getValueR(int color){
                            return red;
                    public int getValueG(int color){
                            return green;
                    public int getValueB(int color){
                            return blue;
                    public void paintComponent(Graphics comp) {
                            Graphics2D comp2D = (Graphics2D)comp;
                            comp2D.fillRect(0,0, 100, 210);
                            Color JL = new Color(red,green,blue);
                            comp2D.setColor(JL);
            public static void main(String[] args) {
                    Slider frame = new Slider();
                    frame.pack();
                    frame.setVisible(true);
                    frame.show();
      /*      class Rectgl extends JPanel {
                    public void paintComponent(Graphics comp) {
                            Graphics2D comp2D = (Graphics2D)comp;
                            comp2D.fillRect(0,0, 100, 210);
                            Color JL = new Color(red,green,blue);
                            comp2D.setColor(JL);

    Thank you, sorry forgot that message. Could you please put it here again, extensively commented, explain why you changed position of Rectgl.class, what other methods you added do?
    Thanks.

  • FindClass can't find a class. need  HELP.

    In my C++ code,
    JavaVMOption options[2];
    JavaVMInitArgs vmArgs;
    options[0].optionString=(char*)"-Djava.class.path=/javahome/V1.3/lib/dt.jar:/javahome/V1.3/lib/tools.jar:/javahome/V1.3/jre/lib/rt.jar:/javahome/V1.3/jre/lib/i18n.jar:/myapps/lib/myLib.jar";
    options[1].optionString = (char *) "-Djava.compiler=NONE";
    vmArgs.version=JNI_VERSION_1_2;
    vmArgs.options=options;
    vmArgs.nOptions=2;
    vmArgs.ignoreUnrecognized=JNI_FALSE;
    JNI_CreateJavaVM( &jvm, (void**)&ev, &vmArgs ));
    if(env->FindClass(my_apple_class)==NULL)
    fprintf(stderr, "Can't find my_apple_class !\n");
    else
    fprintf(stderr,"Found my_apple_class! \n");
    my_apple_class is in /myapps/lib/myLib.jar
    I am getting "Can't find my_apple_class!".
    Would anyone please explain to me why ?
    Thanks,
    --- Won k.

    I am getting "Can't find my_apple_class!".
    Would anyone please explain to me why ?The simple answer is because that it does not exist in the classpath.
    Since you neglected to tell us what the fully qualified class name is of the class that you are trying to load, as well as the value of the my_apple_class variable, it is impossible to say what the root of the problem is.

  • Variables expression in the JDBC. problems need help!

    Dear Sir,
    I am a beginner of using JDBC. I have a problem in the variable expression.
    the fragment code is below
    int today = 20041009;
    ResultSet rs = statement.executeQuery("select * from recorder where bookeddate >= 'today' order by bookeddate");
    I want to order the "booked date" and select the date after today. Unfortunately, it doesn't work. Any person can tell me how to add variable 'today' in to the SQL? I used mySQL
    If this question is tooo stupid, please forgive me.
    Thanks
    Daan

    Dear Sir,
    I am a beginner of using JDBC. I have a problem in the
    variable expression.
    the fragment code is below
    int today = 20041009;
    ResultSet rs = statement.executeQuery("select * from
    recorder where bookeddate >= 'today' order by
    bookeddate");
    I want to order the "booked date" and select the date
    after today. Unfortunately, it doesn't work. Any
    person can tell me how to add variable 'today' in to
    the SQL? I used mySQL
    If this question is tooo stupid, please forgive me.
    what type of field is bookeddate.. a DATE or TIMESTAMP?
    the format you have is a TIMESTAMP.
    once you have solved the problem of actually including the variable in your query (as the previous poster mentioned) if you still have difficulty make sure you are using the right format for the given field.
    you might well want to look at using prepared statements as well because they will handle the formatting for you.. you will need to convert your int variable today into an actual Date object though.

  • Using Elements 7 and cannot change name and email.  Need help

    I am trying to change Photoshop Elements 7 log in name and email and it will not let me do this.  What do I need to do?

    Where are you trying to login?  PSE7 didn't require to login anywhere buy#t if you created a photoshop.com account then it is gone forever.  Instead, Adobe now uses Revel but please tell us where are you trying to login.

  • Struggling to create reports with dynamic names.... need help

    Hi everyone
    The reports that I create need to be named with dynamic content from the database. I did try to find if such an option exists in oracle portal, but alas to no avail. My report templates are going to be the same , but as the report content changes so should the report title. Does anyone has a solution to my problem
    Thanx in anticipation

    sorry ..it was silly of me ... i just found out the solution

  • Variable(?) name in NQSConfig.INI [ REPOSITORY ] section

    Originally I had this entry in my environment
    BIEE = BIC2G_EE.rpd, DEFAULT;
    in Classroom for BI EE course
    Star = appdev.rpd, DEFAULT;
    Where was declared this (variable?) name (eg. BIEE or Star) ?
    Is it arbitrary name ?

    .RPD is a repository file which reads the Metadata from the data source , so when you set the Star variable make sure you have the DSN set up and you have stopped BI server and BI presentation services.

  • Declare a variable in an Interface

    hi all
    can i declare a variable in a interface , something like
    public static final String dsn=" // something";
    so that i dont have to declare the same thing in all the classes that implement this interface
    regards

    You don't need the public, static, or final. All fields in interfaces are implictly public static final fields.

  • Would like to declare a variable Public/Global in an IF statement

    Is there way to declare a variable as Public in an IF statement. My goal is to declare the variable as global (since this variable is used somewhere in the code and should not get initialized when there is loop back to the top of the code, hence using IF statement to control the initialization) based on the IF condition and then use it elsewhere in the code.
    I have it like this
    if (!sei_second_jsp.equals("1"))
    public int[] mecitem;
    public String[] sei_mfg_prod_cat;
    public String[] sei_part_number;
    public String[] sei_descrip;
    public String[] sei_price;
    public int[] sei_onhand;
    public int[] sei_demand;
    mecitem = new int[20000];
    sei_mfg_prod_cat = new String[20000];
    sei_part_number = new String[20000];
    sei_descrip = new String[20000];
    sei_price = new String[20000];
    sei_onhand = new int[20000];
    sei_demand = new int[20000];
    for (int i=0; i<=19999; i++)
    mecitem[i] = 0;
    sei_mfg_prod_cat[i] = " ";
    sei_part_number[i] = " ";
    sei_descrip[i] = " ";
    sei_price[i] = " ";
    sei_onhand[i] = 0;
    sei_demand[i] = 0;
    Your guess is right, I am using this code in JSP - since this is a Java related question, thought of posting it in JAVA forum.
    When I use the above code, I get the following error
    1809 }' expected. { 
    1811 Statement expected. public int[] mecitem;
    1827 Identifier expected. mecitem = new int[20000];
    1827 Can't specify array dimension in a declaration. mecitem = new int[20000];
    1827 Identifier expected. mecitem = new int[20000];
    1837 Can't specify array dimension in a declaration. sei_onhand = new int[20000];
    1837 Identifier expected. sei_onhand = new int[20000];
    1839 Can't specify array dimension in a declaration. sei_demand = new int[20000];
    1839 Identifier expected. sei_demand = new int[20000];
    3117 Class or interface declaration expected. }

    Please note the above code in the JSP is submitting to itself and I donot want it to get initialized if the IF statement is not successful..
    thnks a lot for your time.. !!!

  • Why do we declare the variables private in a bean

    Hi,
    when we create a bean in the MVC architecture why do we declare the variables private. Also when do we use the access specifier private.
    Regards,
    Prashant

    pksingh79 wrote:
    Hi ^^,
    thanks for replying.I had a discussion with one of my trainers and he was of the opinion that the variables should generally be declared private. In this way we prevent classes from accessing and setting illegal values to those variables.
    Say for instance we have the class person as follows:
    public class Person
    int age;
    setAge(int age)
    if (age < 0)
    return null
    Person p = new Person() ;
    p.age = -2;
    //this would be perfectly legal
    //where as if we declare the variable as private as follows:
    public class Person
    private int age;
    setAge(int age)
    if (age < 0)
    return null
    Person p = new Person() ;
    // P.age = -2;   this would be illegal as age is private and would have to be accessed by the method defined above.
    p.setAge(-2);
    //the cbove line would retun null values.
    public class Person {
        private int age;
        public void setAge(int age) {
            if (age < 0) {
                throw new IllegalArgumentException("...");
            this.age = age;
    }

  • How to declare local variables in PL/SQL stored programs

    Where do I declare local variables in a PL/SQL stored program?
    I get compiler errors with either of the options below:
    FUNCTION GET_PRINCIPAL_BALANCE (CUT_OFF_DATE IN DATE, TITLE_SN IN DATE, TOTAL_BALANCE OUT NUMBER) RETURN NUMBER IS
    TOTAL_BALANCE NUMBER;
    BEGIN
    RETURN TOTAL_BALANCE;
    END;
    FUNCTION GET_PRINCIPAL_BALANCE (CUT_OFF_DATE IN DATE, TITLE_SN IN DATE, TOTAL_BALANCE OUT NUMBER) RETURN NUMBER IS
    BEGIN
    TOTAL_BALANCE NUMBER;
    RETURN TOTAL_BALANCE;
    END;

    Your local variable cannot have the same name as the formal out parameter. This is a procedure example, but since functions should not have out parameters anyway ...
    session2> CREATE PROCEDURE p (p_id IN NUMBER, p_did OUT NUMBER) AS
      2     p_did NUMBER;
      3  BEGIN
      4     p_did := p_id * 2;
      5  END;
      6  /
    Warning: Procedure created with compilation errors.
    session2> show error
    Errors for PROCEDURE P:
    LINE/COL ERROR
    0/0      PL/SQL: Compilation unit analysis terminated
    1/1      PLS-00410: duplicate fields in RECORD,TABLE or argument list are
             not permittedThe proper way to create a function would be something like:
    CREATE FUNCTION f (p_id IN NUMBER) RETURN NUMBER AS
       l_did NUMBER;
    BEGIN
      l_did := p_id * 2;
      RETURN l_did;
    END;You should really assign a value to the variable before you return it.
    John

  • Variable textArea not found in class javax.swing.JFrame...

    Making progress on this issue -- but still stuck. Again trying to get the text from a JTextArea on exit:
            frame.addWindowListener
           (new WindowAdapter() {
             public void windowClosing(WindowEvent e)
                System.out.println("Why me???" + frame.textArea.getText());
            });User MARSIAN helped me understand the scope fo the variables and now that has been fixed. Unfortunately I cannot access my variable textArea in the above code. If get this error:
    Error: variable textArea not found in class javax.swing.JFrame
    What am I doing wrong?
    import  java.net.*;
    import  javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import FragImpl.*;
    public class Framework extends WindowAdapter {
        public int numWindows = 0;
        private Point lastLocation = null;
        private int maxX = 500;
        private int maxY = 500;
        JFrame frame;
        public Framework() {
            newFrag();
            Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
            maxX = screenSize.width - 50;
            maxY = screenSize.height - 50;
            makeNewWindow();
        public void makeNewWindow() {
            frame = new MyFrame(this);  //*
            numWindows++;
            System.out.println("Number of windows: " + numWindows);
            if (lastLocation != null) {
                //Move the window over and down 40 pixels.
                lastLocation.translate(40, 40);
                if ((lastLocation.x > maxX) || (lastLocation.y > maxY)) {
                    lastLocation.setLocation(0, 0);
                frame.setLocation(lastLocation);
            } else {
                lastLocation = frame.getLocation();
            System.out.println("Frame location: " + lastLocation);
            frame.setVisible(true);
            frame.addWindowListener
           (new WindowAdapter() {
             public void windowClosing(WindowEvent e)
                System.out.println("Why me???" + frame.textArea.getText());
        //This method must be evoked from the event-dispatching thread.
        public void quit(JFrame frame) {
            if (quitConfirmed(frame)) {
                System.exit(0);
            System.out.println("Quit operation not confirmed; staying alive.");
        private boolean quitConfirmed(JFrame frame) {
            String s1 = "Quit";
            String s2 = "Cancel";
            Object[] options = {s1, s2};
            int n = JOptionPane.showOptionDialog(frame,
                    "Windows are still open.\nDo you really want to quit?",
                    "Quit Confirmation",
                    JOptionPane.YES_NO_OPTION,
                    JOptionPane.QUESTION_MESSAGE,
                    null,
                    options,
                    s1);
            if (n == JOptionPane.YES_OPTION) {
                return true;
            } else {
                return false;
         private void newFrag()
              Frag frag = new FragImpl();
        public static void main(String[] args) {
            Framework framework = new Framework();
    class MyFrame extends JFrame {
        protected Dimension defaultSize = new Dimension(200, 200);
        protected Framework framework = null;
        private Color color = Color.yellow;
        private Container c;
        JTextArea textArea;
        public MyFrame(Framework controller) {
            super("New Frame");
            framework = controller;
            setDefaultCloseOperation(DISPOSE_ON_CLOSE);
            setSize(defaultSize);
            //Create a text area.
            textArea = new JTextArea(
                    "This is an editable JTextArea " +
                    "that has been initialized with the setText method. " +
                    "A text area is a \"plain\" text component, " +
                    "which means that although it can display text " +
                    "in any font, all of the text is in the same font."
            textArea.setFont(new Font("Serif", Font.ITALIC, 16));
            textArea.setLineWrap(true);
            textArea.setWrapStyleWord(true);
            textArea.setBackground ( Color.yellow );
            JScrollPane areaScrollPane = new JScrollPane(textArea);
            //Create the status area.
            JPanel statusPane = new JPanel(new GridLayout(1, 1));
            ImageIcon icoOpen = null;
            URL url = null;
            try
                icoOpen = new ImageIcon("post_it0a.gif"); //("doc04d.gif");
            catch(Exception ex)
                ex.printStackTrace();
                System.exit(1);
            setIconImage(icoOpen.getImage());
            c = getContentPane();
            c.setBackground ( Color.yellow );
            c.add ( areaScrollPane, BorderLayout.CENTER )  ;
            c.add ( statusPane, BorderLayout.SOUTH );
            c.repaint ();
    }

    Yeah!!! It works. Turned out to be a combination of DrKlap's and Martisan's suggestions -- had to change var frame's declaration from JFrame to MyFrame:
        MyFrame frame;Next, created the external class -- but again changed JFrame references to MyFrame:
    public class ShowOnExit extends WindowAdapter {
    //   JFrame aFrame;
       MyFrame aFrame;
       public ShowOnExit(MyFrame f) {
          aFrame = f;
       public void windowClosing(WindowEvent e)
          System.out.println("Why me???" + aFrame.textArea.getText()); // aFrame here not frame !!!
    }This worked. So looks like even though the original code added a WindowListener to 'frame', the listener didn't couldn't access frame's methods unless it was explicitly passed in as a parameter. Let me know if that's wrong.
    Thanks again, all.

  • Using variable coulmn name in sql function

    Hi there,
    I am not an expert with PL/SQL and I can not figure out how to use variable column names in my function.
    My function is:
    CREATE OR REPLACE FUNCTION RESET_TRIGGERS(aTrigger VARCHAR2) RETURN NUMBER IS
    TEMP_ID NUMBER;
    TEMP_USER_ID NUMBER;
    BEGIN
    SELECT 'LIMS.'||'$aTrigger'||'.NEXTVAL' INTO TEMP_ID FROM DUAL;
    SELECT 'LIMS.'||'$aTrigger'||'_USER.NEXTVAL' INTO TEMP_USER_ID FROM DUAL;
    IF TEMP_ID > TEMP_USER_ID THEN
    LOOP
    SELECT LIMS.SQ_U_FINALRESULT_USER.NEXTVAL INTO TEMP_USER_ID FROM DUAL;
    EXIT WHEN TEMP_USER_ID = TEMP_ID;
    END LOOP;
    ELSE
    WHILE TEMP_ID < TEMP_USER_ID LOOP
    SELECT LIMS.SQ_U_FINALRESULT.NEXTVAL INTO TEMP_ID FROM DUAL;
    END LOOP;
    END IF;
    COMMIT;
    RETURN (TEMP_ID);
    END;
    What I want is that I pass a seqencename with aTrigger and that two triggers will be equal if not.
    eg ifaTrigger = 'SQ_U_FINALRESULT'
    than I want the triggers LIMS.SQ_U_FINALRESULT and LIMS.SQ_U_FINALRESULT_USER to be set equal.
    The above function will not work, but what will?????
    I hope you can help me out!
    Cheers

    A very strange function indeed.
    But here is what I think he meant to do:
    SQL> create procedure reset_sequences
      2  ( p_sequence_name in  varchar2
      3  , p_nextval          out number
      4  )
      5  is
      6    l_nextval1 number;
      7    l_nextval2 number
      8    ;
      9    procedure reset_sequence_value
    10    ( p_sequence_name in varchar2
    11    , p_current_value in number
    12    , p_new_value     in number
    13    )
    14    is
    15      l_dummy number;
    16    begin
    17      execute immediate 'alter sequence ' || p_sequence_name || ' increment by ' || to_char(p_new_value-p_current_value);
    18      execute immediate 'select ' || p_sequence_name || '.nextval from dual' into l_dummy;
    19      execute immediate 'alter sequence ' || p_sequence_name || ' increment by 1';
    20    end reset_sequence_value
    21    ;
    22  begin
    23    execute immediate
    24      'select ' || p_sequence_name || '.nextval,' || p_sequence_name || '_user.nextval from dual'
    25    into l_nextval1, l_nextval2
    26    ;
    27    if l_nextval1 < l_nextval2
    28    then
    29      reset_sequence_value(p_sequence_name,l_nextval1,l_nextval2);
    30    end if
    31    ;
    32    if l_nextval1 > l_nextval2
    33    then
    34      reset_sequence_value(p_sequence_name || '_user',l_nextval2,l_nextval1);
    35    end if
    36    ;
    37    p_nextval := greatest(l_nextval1,l_nextval2)
    38    ;
    39  end reset_sequences;
    40  /
    Procedure is aangemaakt.
    SQL> show err
    Er zijn geen fouten.
    SQL> create sequence testseq start with 5 increment by 1
      2  /
    Reeks is aangemaakt.
    SQL> create sequence testseq_user start with 2 increment by 1
      2  /
    Reeks is aangemaakt.
    SQL> declare
      2    l_new_value number;
      3  begin
      4    reset_sequences('testseq',l_new_value);
      5    dbms_output.put_line(l_new_value);
      6  end;
      7  /
    5
    PL/SQL-procedure is geslaagd.
    SQL> select testseq.currval from dual
      2  /
                                   CURRVAL
                                         5
    1 rij is geselecteerd.
    SQL> select testseq_user.currval from dual
      2  /
                                   CURRVAL
                                         5
    1 rij is geselecteerd.Regards,
    Rob.

  • Autocomplete Declared PHP Variables in Dreamweaver

    Is there a way to autocomplete php variables that have been
    declared? For instance, whenever you type $ in a PHP code block, a
    pop up list would automatically come up with all the variables you
    have already declared. This would GREATLY speed up coding and help
    to insure coding accuracy.
    If there is a way to do this now, could someone please clue
    me in? I've searched and searched forums, help files, and google.
    If this is not available, where should I go to request this
    feature?
    Shanna

    jsteinmann wrote:
    > With asp.net missing, along with several other things
    discontinued, dreamweaver will have to cater to php developers in
    these kinds of ways.
    If you want Dreamweaver to add features posting this sort of
    comment in
    a user-to-user forum won't have the slightest impact on the
    direction
    that Dreamweaver actually takes. You need to make your views
    known by
    submitting feature requests through the official channel:
    http://www.adobe.com/cfusion/mmform/index.cfm?name=wishform
    Submitting requests doesn't guarantee that your ideas will be
    adopted in
    the next version or even the one after that, but it does get
    them on the
    development team's radar.
    David Powers, Adobe Community Expert
    Author, "The Essential Guide to Dreamweaver CS3" (friends of
    ED)
    Author, "PHP Solutions" (friends of ED)
    http://foundationphp.com/

  • Declaring a variable in a function: either the function or the eventListener I'm using doesn't work

    Can anyone help me with this?
    I have a set of Cue Points in an FLV I'm playing. It's an interactive quiz, so the idea is that flash will change a variable, theAnswer, to a different letter depending on which question it is. The answer to question 1 is B, question 2 is D, etc.
    Either the cue point event listener isn't working, or else it is working and Flash isn't declaring the variables. Can someone help?
    The error message I get is:
    1120: Access of undefined property theAnswer.
    I literally can't find a single problem with my code. I have an almost identical Event Listener further down which works.
    var theAnswer;
    vid.addEventListener(MetadataEvent.CUE_POINT, cueAnswers);
    function cueAnswers(e:MetadataEvent):void{
    var cuePointNames = e.info.name;
    if (cuePointNames =="start")
    theAnswer = "C";
    else if (cuePointNames =="q2")
    theAnswer = "A";
    else if (cuePointNames =="q3")
    theAnswer = "C";
    else if (cuePointNames =="q4")
    theAnswer = "A";
    else if (cuePointNames =="q5")
    theAnswer = "D";
    else if (cuePointNames =="q6")
    theAnswer = "C";
    else if (cuePointNames =="q7")
    theAnswer = "A";
    else if (cuePointNames =="q8")
    theAnswer = "D";
    else if (cuePointNames =="q9")
    theAnswer ="B"
    else if (cuePointNames =="q10")
    theAnswer ="B";
    The function is called by this later:
    function nkAinfo(e:MouseEvent):void {
    if (theAnswer=="C")
    trace("You clicked right");
    else
    trace("You clicked wrong");
    What's going on? Is the function not being called or are my variable declarations wrong?

    Probably not the answer to your question, but it could help anyways....
    First there is another command that, to me at least, is much easier to read that a bunch of nested if/if elses. And that is the switch.
    switch (e.info.name){
    case "start":
    theAnswer="C";
    break;
    case "q2":
    theAnswer="A"
    break;
    //and so on
    To me that is easier to maintain and read. But I don't think that is really what you need here. So just file that one away for the future.
    In this case, what I think you need is an array.
    var currentAnswer:String;
    var correctAnswers:Array=new Array();
    correctAnswers["start"]="C"
    correctAnswers["q2"]="A"
    // and so on.
    Then your cuepoint handler function becomes something like this:
    function cueAnswers(e:MetadataEvent):void{
         currentAnswer=correctAnswers[e.info.name];
    And I'm a little confused by your mouse click handler. It would seem to suggest that the answer is always "C"? But I"m guessing that it is supposed to compare what the user clicked on to what the cuePoint has told it is the correct answer? Well if that is the case then it would probably look something like:
    function nkAinfo(e:MouseEvent):void {
    if(e.currentTarget.clickedProperty==currentAnswer){
         trace("Correct");
    } else {
         trace("Incorrect");
    With the way you are currently doing this I'm guessing that you have a bunch of repeated functions for each time there is a mouse click and that your code is a lot more complicated that it needs to be. And that somewhere hiding in all those lines there is an error that would be simple to fix if you could see it.
    What the error is telling you is that somewhere your are trying to assign or retrieve theAnswer and it hasn't been defined yet.

Maybe you are looking for