About Class Object  as Array

Hello.. I'm beginner in Java Programming
Now i learn about Array.. i'm not understand about use class object become array. for example i'm create class object Card.
Then i call Card object to CardTest as main object and Card object called as array.
can you tell me about how to work Card object as array in CardTest ?
Edited by: 994075 on Mar 14, 2013 11:55 PM

994075 wrote:
yup..thanks guru :DI'm no guru, I just bought a decent Java book 10 years ago and here I am.
so i guess Object Class can be array :).I don't get that statement. You can store objects in an array, if that's what you mean. An array itself is also an object.
but i'm not understrand if static method in Card object can be called automatically when Card initialized in CardTest?a) research constructors
b) you usually don't need static methods, its just something that people new to the language tend to overuse because then you don't have to create object instances. Forget about static methods, try to make it work using regular non-static methods.
And you really should read and study more, you're coming to the forum way too soon. First get a solid knowledge base, the only thing you're doing now is asking questions that you could have answered for yourself by studying more.

Similar Messages

  • As 2.0 class objects- how to swap depths of a movie clip

    How do you bring an object to the top? if it's just a movie
    clip, I could do a swapdepths, but if it's a movieclip that's part
    of an AS 2.0 object, how do you swap depths of the whole object?
    I create 2 objects (same class) which each have a movieclip
    within them. The movie clip is created on a unique level with
    getNextHighestDepth().
    I have a button which tries to swapDepths of the 2 objects,
    but I can't get it to work. Can anyone help?
    here's the detail:
    1. create a symbol in the library called "someShape_mc" and
    put some shape in it - a circle, a square, whatever - this symbol
    is exported for action script, and has an AS 2.0 Class of
    "ClassObject" ( I also put a dynamic text field in the shape to
    display the current depth - it's called "depth_txt")
    2. create a button called "swap_btn" on the stage.
    Frame 1 has the following actionscript:
    var BottomObject:ClassObject = new ClassObject(this,100,150);
    var topObject:ClassObject = new ClassObject(this,110,160);
    // for the button add this:
    Swap_btn.onRelease=function() {
    // try it with the full path:
    _root.BottomObject.__LocalMovieClip.swapDepths(_root.topObject.__LocalMovieClip);
    // try it with with just the objects:
    BottomObject.__LocalMovieClip.swapDepths(topObject.__LocalMovieClip);
    // try it with the object as a movieclip
    BottomObject.swapDepths(topObject);
    trace("Did it Swap?");
    // try it with a method in the class....
    BottomObject.swapIt(topObject.__LocalMovieClip);
    BottomObject.swapIt(topObject);
    trace("nope... no swapping going on...");
    ================================
    here's the AS file: "ClassObject.as"
    class ClassObject extends MovieClip{
    var __LocalMovieClip;
    var __Depth;
    function ClassObject(passedIn_mc:MovieClip,x:Number,y:Number)
    __Depth = passedIn_mc.getNextHighestDepth();
    __LocalMovieClip =
    passedIn_mc.attachMovie("someShape_mc","__LocalMovieClip",__Depth);
    trace("made a shape at " + __Depth);
    __LocalMovieClip._x = x;
    __LocalMovieClip._y = y;
    __LocalMovieClip.depth_txt.text = __Depth;
    public function swapIt(targetMc) {
    __LocalMovieClip.swapDepths(targetMc);
    __LocalMovieClip.depth_txt.text =
    __LocalMovieClip.getDepth(); // no difference.
    trace("Tried to swap from within the class...");
    ========================
    so- the goal is to bring the "bottom" Class object on top of
    the "top" object. The button tries various methods of swapping the
    depths of the movie clips - but there is not one that works. What
    am I missing?
    tia
    ferd

    Thank you for your response - and here I have included the
    code I reworked to show how it works, and doesn't work. you're
    right about not needing the extra containers, but this example is
    part of a bigger thing...
    I'm confused - it works ONLY if I attach the movie outside
    the class, even though the "attachment" occurs, I'm thinking, at
    the same scope level, that is, _root.holder_mc, in both examples.
    it seems that the advantage of having a class is defeated
    since I have to do the extra coding for each object that will be
    created. It's like the class can only have a reference to the
    movieclip outside itself, and not have a clip INSIDE that is fully
    functioning. am I right about this? Is there someplace good I can
    learn more about class objects and movieclip usage?
    also, my class object IS a movieclip, but " this.getDepth() "
    is meaningless inside the class object. hmmm...
    This one works..... attaching the movies at the root level
    (to a holder_mc)
    // Frame 1
    tmp1 =
    holder_mc.attachMovie("someShape_mc","tmp1",holder_mc.getNextHighestDepth());
    var BottomObject:ClassObject3 = new
    ClassObject3(tmp1,100,150);
    tmp2 =
    holder_mc.attachMovie("someShape_mc","tmp2",holder_mc.getNextHighestDepth());
    var topObject:ClassObject3 = new ClassObject3(tmp2,110,160);
    // for the button add this:
    Swap_btn.onRelease=function() {
    BottomObject.swapIt(topObject);
    trace("clicked button");
    // ClassObject3.as
    class ClassObject3 extends MovieClip{
    var __LocalMovieClip:MovieClip;
    function
    ClassObject3(passedInMovieClip:MovieClip,x:Number,y:Number) {
    trace(" this class object is at ["+this.getDepth()+"]");
    __LocalMovieClip = passedInMovieClip;
    __LocalMovieClip._x = x;
    __LocalMovieClip._y = y;
    public function swapIt(targetMc:MovieClip):Void {
    trace("do the swap in the class");
    trace("===========================");
    trace("target type :" + typeof(targetMc));
    trace("__LocalMovieClip type :" + typeof(__LocalMovieClip));
    __LocalMovieClip.swapDepths(targetMc.__LocalMovieClip);
    This one does NOT work..... attaching the movies within the
    class object...
    // Frame 1
    var BottomObject:ClassObject2 = new
    ClassObject2(holder_mc,100,150);
    var topObject:ClassObject2 = new
    ClassObject2(holder_mc,110,160);
    // for the button add this:
    Swap_btn.onRelease=function() {
    BottomObject.swapIt(topObject);
    trace("clicked button");
    // ClassObject2.as
    class ClassObject2 extends MovieClip{
    var __LocalMovieClip:MovieClip;
    function
    ClassObject2(passedInMovieClip:MovieClip,x:Number,y:Number) {
    __LocalMovieClip =
    passedInMovieClip.attachMovie("someShape_mc","stuff1",passedInMovieClip.getNextHighestDep th());
    __LocalMovieClip._x = x;
    __LocalMovieClip._y = y;
    public function swapIt(targetMc:MovieClip):Void {
    trace("do the swap in the class");
    trace("===========================");
    trace("target type :" + typeof(targetMc));
    trace("__LocalMovieClip type :" + typeof(__LocalMovieClip));
    __LocalMovieClip.swapDepths(targetMc.__LocalMovieClip);

  • Multidimensional array in jquery class/object

    I'm trying to get into javascript and jquery for a hobby project of mine. Now I've used the last 4 hours trying to find a guide on how to create class objects that can contain the following information
    Identification : id
    Group : group
    Persons : array(firstname : name, lastname : name)
    Anyone know of a tutorial that can show me how to do this?
    I found this page where I can see that an object can contain an array, but it doesn't state whether it is possible to use a multidimensional array.
    And this page just describes the object with normal values.
    Any pointers in the right direction are appreciated.

    There are no classes in JavaScript. It uses a different style of objects and what you found is indeed what you need.
    Well, it might help to think about it as a dynamic, runtime-modifiable object system. An Object is not described by class, but by instructions for its creation.
    Here you have your object. Note that you can use variables everywhere.
    var id = 123;
    var test = {"Identification": id,
    "Group": "users",
    "Persons": [{"firstname":"john", "lastname":"doe"},{"firstname":"jane","lastname":"doe"}]
    This is identical to the following code. (The first one is a lot nicer, though.)
    var id = 123;
    var test = new Object();
    test.Identification = id;
    test["Group"] = "users;
    test.Persons = new Array();
    test.Persons.push({"lastname":"doe","lastname":"john"});
    test.Persons.push({"lastname":"doe","lastname":"jane"});
    As you can see, you can dynamically add new properties to an object. You can use both the dot-syntax (object.property) and the hash syntax (object["property"]) in JavaScript.

  • Array of class objects

    I was wondering how would you declare an array of class objects. Here is my situation:
    I'm working on a project dealing with bank accounts. Each customer has a specific ID and a balance. I have to handle transactions for each customer at different times, so I was thinking that I need an array of class objects; however, I dont know how to initialize them.
    Here's what I did:
    BankAccount [ ] myAccount = new BankAccount[10];
    // 10 = 10 customers
    How do I initialize the objects?
    Thankz

    I was wondering how would you declare an array of
    class objects. Here is my situation:
    I'm working on a project dealing with bank accounts.
    Each customer has a specific ID and a balance. I have
    to handle transactions for each customer at different
    times, so I was thinking that I need an array of
    class objects; however, I dont know how to initialize
    them.
    Here's what I did:
    BankAccount [ ] myAccount = new BankAccount[10];
    // 10 = 10 customers
    How do I initialize the objects?
    Thankz
    HAI
    Use the hashtable
    and store the classObject of each customer with the corresponding Id in it
    and whenever u want to recover a class match the Id and get the corresponding class
    that is the best way to solve ur problem
    Regards
    kamal

  • Class Object into Byte Array

    Is there a way to copy a class object into a byte array? If so, how?

    hi check out
    http://forum.java.sun.com/thread.jspa?threadID=562268&
    messageID=2766098This does not work in j2me. WriteObject does not exist, and there are no serialsation interfaces in j2me. So you'll have to do that on your own.
    look here: http://java.sun.com/developer/J2METechTips/2002/tt0226.html

  • Create array of arbitrary dimensions / get Class object for primitive types

    Here's an interesting problem: is there any way to code for the creation of an n-dimensional array where n is only known at runtime (input by user, etc.)?
    java.lang.reflect.Array has a newInstance method which returns an array of an arbitrary number of dimensions specified by the int[] argument, which would give me what I want. However, the other argument is a Class object representing the component type of the array. If you want to use this method to get an array of a primitive type, is it possible to get a Class object representing a primitive type?

    That doesn't help, since the whole problem is that the number of dimensions aren't known until runtime. You can't simply declare a variable of type int[][] or use an int[][] cast, since the number of []'s is variable.
    The int.class construction was partly what I was looking for. This returns the array needed (assuming some read method):
    int dimensions = read();
    int size = read();
    int[] index = new int[dimensions];
    for (int i = 0; i < dimensions; i++)
        index[i] = size;
    Object myArray = Array.newInstance(int.class, index);The only problem is, as an Object, I can't use myArray usefully as an array. And I can't use a cast, since that requires a fixed number of dimensions.

  • Create Class objects from an Array of File Objects

    Hi There,
    I'm having extreme difficulty in trying to convert an array of file objects to Class objects. My problem is as follows: I'm using Jfilechooser to select a directory and get an array of files of which are all .class files. I want to create Class objects from these .class files. Therefore, i can extract all the constructor, method and field information. I eventually want this class information to display in a JTree. Very similar to the explorer used in Netbeans. I've already created some code below, but it seems to be throwing a NoSuchMethodError exception. Can anyone please help??
    Thanks in advance,
    Vikash
    /* the following is the class im using */
    class FileClassLoader extends ClassLoader {
    private File file;
    public FileClassLoader (File ff) {
    this.file = ff;
    protected synchronized Class loadClass() throws ClassNotFoundException {
    Class c = null;
    try {
    // Get size of class file
    int size = (int)file.length();
    // Reserve space to read
    byte buff[] = new byte[size];
    // Get stream to read from
    FileInputStream fis = new FileInputStream(file);
    DataInputStream dis = new DataInputStream (fis);
    // Read in data
    dis.readFully (buff);
    // close stream
    dis.close();
    // get class name and remove ".class"
    String classname = null;
    String filename = file.getName();
    int i = filename.lastIndexOf('.');
    if(i>0 && i<filename.length()-1) {
    classname = filename.substring(0,i);
    // create class object from bytes
    c = defineClass (classname, buff, 0, buff.length);
    resolveClass (c);
    } catch (java.io.IOException e) {
    e.printStackTrace();
    return c;
    } // end of method loadClass
    } // end of class FileClassLoader
    /* The above class is used in the following button action in my gui */
    /* At the moment im trying to output the data to standard output */
    private void SelectPackage_but2ActionPerformed(java.awt.event.ActionEvent evt) {
    final JFileChooser f = new JFileChooser();
    f.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    int rVal = f.showOpenDialog(Remedy.this);
    // selects directory
    File dir = f.getSelectedFile();
    // gets a list of files within the directory
    File[] allfiles = dir.listFiles();
    // for loop to filter out all the .class files
    for (int k=0; k < allfiles.length; k++) {
    if (allfiles[k].getName().endsWith(".class")) {
    try {
    System.out.println("File name: " + allfiles[k].getName()); // used for debugging
    FileClassLoader loader = new FileClassLoader(allfiles[k]);
    Class cl = loader.loadClass();
    //Class cl = null;
    Class[] interfaces = cl.getInterfaces();
    java.lang.reflect.Method[] methods = cl.getDeclaredMethods();
    java.lang.reflect.Field[] fields = cl.getDeclaredFields();
    System.out.println("Class Name: " + cl.getName());
    //print out methods
    for (int m=0; m < methods.length; m++) {
    System.out.println("Method: " + methods[m].getName());
    // print out fields
    for (int fld=0; fld < fields.length; fld++) {
    System.out.println("Field: " + fields[fld].getName());
    } catch (Exception e) {
    e.printStackTrace();
    } // end of if loop
    } // end of for loop
    packageName2.setText(dir.getPath());
    }

    It's throwing the exeption on the line:
    FileClassLoader loader = new FileClassLoader(allfiles[k]);
    I'm sure its something to do with the extended class i've created. but i cant seem to figure it out..
    Thanks if you can figure it out

  • Re: Beginner needs help using a array of class objects, and quick

    Dear Cynthiaw,
    I just read your Beginner needs help using a array of class objects, and quick of Dec 7, 2006 9:25 PM . I really like your nice example.
    I also want to put a question on the forum and display the source code of my classe in a pretty way as you did : with colors, indentation, ... But how ? In html, I assume. How did you generate the html code of your three classes ? By help of your IDE ? NetBeans ? References ?
    I already posted my question with six source code classes ... in text mode --> Awful : See "Polymorphism did you say ?"
    Is there a way to discard and replace a post (with html source code) in the Sun forum ?
    Thanks for your help.
    Chavada

    chavada wrote:
    Dear Cynthiaw,
    I just read your Beginner needs help using a array of class objects, and quick of Dec 7, 2006 9:25 PM . I really like your nice example.You think she's still around almost a year later?
    I also want to put a question on the forum and display the source code of my classe in a pretty way as you did : with colors, indentation, ... But how ?Just use [code] and [/code] around it, or use the CODE button
    [code]
    public class Foo() {
      * This is the bar method
      public void bar() {
        // do stuff
    }[/code]

  • Arrays of arbitrary dimensions / Class object for primitive types

    Here's an interesting problem: is there any way to code for the creation of an n-dimensional array where n is only known at runtime (input by user, etc.)?
    java.lang.reflect.Array has a newInstance method which returns an array of an arbitrary number of dimensions specified by the int[] argument, which would give me what I want. However, the other argument is a Class object representing the component type of the array. If you want to use this method to get an array of a primitive type, is it possible to get a Class object representing a primitive type?

    Devil is in the detailspublic class Test2 {
      public static void main(String[] args) {
        Object[] myArray = new Object[10];
        fillDimensionalArray(myArray, 5, 5);
      public static void fillDimensionalArray(Object[] array, int dim, int size) {
        if (dim==1) {
          for (int i=0; i<size; i++) {
            array[i] = new int[size];
            for (int j=0; j<size; j++) ((int[])array)[j]=999;
    } else {
    for (int i=0; i<array.length; i++) {
    array[i] = new Object[size];
    for (int j=0; j<size; j++) {
    fillDimensionalArray( (Object[]) array[i], dim - 1, size);

  • Anybogy know anything about PHP Classes & Objects?

    I need some guidance. I've got a problem that I think I know
    the way
    around, but need a bit of help.
    Basically I'm trying to create dynamic classes - which I
    don't think I can
    do. I *should* be able to, but for some reason I can't make
    my mind see how
    to do it.
    I know you can't dynamically name a class - which I guess is
    OK. I can put
    an attribute in the class to define individual names.
    However, I don't know
    exacly how many class objects I will need - and thus I don't
    really know how
    to do this.
    For example,
    I have a class, Group. But I don't know how *many* groups I
    will need. I
    can name a group, but I cannot dynamically create new groups.
    So $GroupName = new Group; is valid - but has to be entered
    into the code
    for every group.
    This
    $DynamicallyGeneratedGroupName = new Group; does not work.
    I guess I could just try to re-use one group, but I'm not
    sure if this will
    work with my templated system, which needs to pair variables
    with HTML code
    (in other words, I need a complete seperation of PHP and
    HTML).
    Does anybody have any suggestions or direction to go with
    this? I'm kinda
    leaving it alone until I can find a bit more info on classes
    or a little
    instruciton on where to look for more info (or demo code of
    re-using class
    objects to populate different data).
    TIA,
    Jon Parkhurst
    PriivaWeb
    http://priiva.net.

    David -
    You've once again made me giggle like a schoolgirl.
    Thank you very much!!
    You're gonna get a big bottle of scotch this year under the
    tree.
    "David Powers" <[email protected]> wrote in message
    news:eacp2e$fdd$[email protected]..
    > crash wrote:
    >> I have a class, Group. But I don't know how *many*
    groups I will need. I
    >> can name a group, but I cannot dynamically create
    new groups.
    >
    > for ($i = 0; $i < $whateverControlsTheMaximum; $i++)
    > $nextOne = "myGroup{$i}";
    > $$nextOne = new Group();
    > }
    >
    > That gives you $myGroup0, $myGroup1, $myGroup3, etc.
    >
    > --
    > David Powers
    > Author, "Foundation PHP for Dreamweaver 8" (friends of
    ED)
    > Author, "Foundation PHP 5 for Flash" (friends of ED)
    >
    http://foundationphp.com/

  • Problem with Dynamically accessing EJB Class objects in WL 7.0 SP1

    I am trying to build a component which has the ability to instantiate and execute
    an known EJB method on the fly.
    I have managed to build the component but when I try and execute it I get a ClassNotFoundException.
    I know that the EJB I am trying to invoke is deployed and available on the server,
    as I can see it in the console, I also seen to have been able to get the remote
    interface of the object, my problem occurs when I try and access the class object
    so I can perform a create on the object and then execute my method
    The code I have written is below:
    private Object getRemoteObject(Context pCtx, String pJNDIName, String pHomeBean)
    throws Exception {
         String homeCreate = "create";
         Class []homeCreateParam = { };
         Object []homeCreateParamValues = {};           
    try {  
    //This call seems to work and doesn't throw an exception     
    Object home = pCtx.lookup(pJNDIName);
    //However this call throws a java.lang.ClassNotFoundException
    Class homeBean = Class.forName(pHomeBean);
    Method homeCreateMethod = homeBean.getMethod(homeCreate,homeCreateParam);
    return homeCreateMethod.invoke(home, homeCreateParamValues);
    } catch (NamingException ne) {             
    logStandardErrorMessage("The client was unable to lookup the EJBHome.
    Please make sure ");
    logStandardErrorMessage("that you have deployed the ejb with the JNDI
    name "+pJNDIName+" on the WebLogic server ");
    throw ne;
    } catch (Exception e) {
    logStandardErrorMessage(e.toString());
    throw e;     
    Any advice would be really appreciated, I'm fast running out of ideas, I suspect
    it has something to do with the class loader but I'm not sure how to resolve it
    Regards
    Jo Corless

    Hello Joanne,
    Congratulations! I'm very happy that you've managed to fix your problem. It's
    always essential to understand how to package applications when deploying on BEA
    WebLogic. Usually, by throwing everything into an EAR file solves just about all
    the class loader problems. :-) Let us know if you have any further problems that
    we can assist you with.
    Best regards,
    Ryan LeCompte
    [email protected]
    http://www.louisiana.edu/~rml7669
    "Joanne Corless" <[email protected]> wrote:
    >
    >
    I've fixed it!!!!!!!!
    Thanks to everyone who gave me help!!!!
    The class loader was the culprit which is what I suspected all along.
    As soon
    as I put the 2 jar files I was using into an EAR file the problem went
    away!!!!!
    Thanks again
    Jo Corless
    "Ryan LeCompte" <[email protected]> wrote:
    Hello Joanne,
    As Mr. Woollen mentioned, I also believe it's a problem with the class
    loader.
    You need to be careful how you arrange your EJBs, because WebLogic has
    a specific
    method in which it loads classes in an EAR, JAR, and WAR file(s). Please
    refer
    to http://dev2dev.bea.com/articles/musser.jsp for more information about
    BEA WebLogic
    class loading mechanisms and caveats. Also, try printing out the various
    methods
    that are available on the object that was returned to you via reflection.
    For
    example, use the getMethods() method, which returns an array of Method
    objects
    that you can subsequently cycle through and print out the various method
    names.
    This way you can discover if the class found/returned to you is indeed
    the one
    you intend to locate.
    Hope this helps,
    Ryan LeCompte
    [email protected]
    http://www.louisiana.edu/~rml7669
    Rob Woollen <[email protected]> wrote:
    I believe the issue is the home interface class for this EJB is not
    available in the class loader which is doing the reflection.
    If you do:
    getClass().getClassLoader().loadClass(homeInterfaceClassName)
    I suspect it will fail. Reflection still requires that the class be
    loadable.
    -- Rob
    Joanne Corless wrote:
    Hi Slava,
    If I make my code look like you describe below I get a compliationerror telling
    me that
    home.getMethod() is not recognised (no such method)
    If I change it slightly and use
    Method homeCreateMethod =
    home.getClass().getMethod(homeCreate,homeCreateParam);
    The code will compile OK but when executed it still throws a NoSuchMethodException
    Any ideas ?
    Thanks for your help so far
    Regards
    Jo Corless
    Your code should look like
    Object home = pCtx.lookup(pJNDIName);
    Method homeCreateMethod =
    home.getMethod(homeCreate,homeCreateParam);
    return homeCreateMethod.invoke(home, homeCreateParamValues);
    Regards,
    Slava Imeshev
    "Joanne Corless" <[email protected]> wrote in message
    news:[email protected]...
    Hi Ryan,
    I also wanted to mention that if you do a "header search" in this
    particular
    newsgroup
    with the search query as "reflection", you will see many previousmessages
    regarding
    reflection and EJBs. I believe you could learn a lot from thedifficulties
    that
    others have faced and solved.I tried that and although there was a number of similar cases noneof them
    actually
    seem to fix my issue. Thanks for the suggestion though
    Are the EJBs that you are trying to access accessible via your
    system
    classpath?
    Try to avoid having them accessible via the main system classpath,and
    only bundle
    them in your appropriate EJB jar files (contained in an EAR file,for
    example).Maybe I should have laid the problem out a little clearer.
    I have a number of EJB's bundled up in a JAR file which is hot deployedto
    the
    server. Within this first JAR file is an EJB (SSB) component that
    needs
    to
    be
    able to invoke a known method on another EJB. This second EJB may
    or
    may
    not be
    within the first JAR file but it also will be hot deployed.
    The component trying to invoke the method on the 2nd EJB has to
    be
    able to
    create
    an instance of the 2nd EJB without actually knowing anything bar
    a
    JNDI
    Name which
    is passed in at runtime.
    I can get as far as doing the
    Object home = pCtx.lookup(pJNDIName);
    This returned a class with the name
    "com.csc.edc.projects.allders.httppostoffice.postman.PostmanBean_mp8qy2_Home
    Impl_WLStub"
    My problem seems to occur when I try and invoke the create method
    Method homeCreate = home.getClass().getMethod("create", new Class[0]);
    My code throws a java.lang.NoSuchMethodException at this point so
    I
    am
    unable
    to progress to the next step of :
    Object bean = homeCreate.invoke(home, null);
    So I can return the instantiated bean back to the calling client.
    Why am I getting the NoSuchMethodException, is is because I am gettinga
    stub
    back rather than the home interface and if so how do I get the truehome
    interface
    from the bean
    Thanks in advance
    Jo Corless

  • Making a lot of class objects.

    What would be the most efficient way to make a lot (50+) of class objects. COuld I make an array ClassName[ ]? Please help. Thanks.

    50 Cards? it's unlikely your card objects are complicated, so this is just a drop in the bucket. Stop worrying about efficiency, unless this is meant to run on a Java-enabled spy quarter, using nano-technology:
    [url #" style="display: block; background-image: url('http://images.theglobeandmail.com/archives/RTGAM/images/20070507/wspycoins0507/0507poppyquarter188.jpg'); width: 188px; height: 186px] 

  • Basic actionscript help, tracing properties of my class object

    Hi all,I'm just starting to learn about classes in actionscript, I am following along with Moocks book Actionscript for Flash MX and are trying to execute a trace on the properties of my ballclass but all I get is undefined. He is what I have in my actions panel.
    function Ball () {
        this.radius = 10;
        this.color = 0xFF0000;
        this.xPosition = 59;
        this.yPosition = 15;
    var boucyBall = new Ball();
    trace (bouncyBall.radius);
    trace (bouncyBall.color);
    trace (bouncyBall.xPosition);
    trace (bouncyBall.yPosition);
    Any help would be great

    Since you are learning about classes, you might want to use one to help you:
    class Util{
    public function Util(){
    // empty constructor because you don't need one for this kind of class
    public static function traceProps(obj:Object,label:String):Void{
    if(label != undefined){
    trace(Properties for "+label+":");
    for(var a in obj){
    trace("   "+a+": "+obj[a]);
    trace(newline);
    Then place that class file somewhere in your class path so it will always be available to you. And then you can always add these lines.
    import com.complexity.Utils;
    If the file is in your class path you don't really need the above line, but it will help you remember that you are using it. Also I'm just making up what your class path might be based upon your screen name. You would need to use whatever actual path you had. And then...
    Utils.traceProps(bouncyBall,"trouble maker here");
    Of course don't use it with an 10,000 element array, unless you really like to suffer.....
    or just
    Utils.traceProps(bouncyBall);

  • How to get a LabVIEW class object to expose an invoke-node method?

    Hi,
          I like the property/invoke-node "paradigm" used for interacting with "objects".  Can LabVIEW-class objects expose their properties and methods this way?  Can one or more LabVIEW-class objects be compiled into a library or "assembly" (or other distrubution format) that allows the property/invoke-node usage?
    I've looked at (but not completely understood) "Creating LabVIEW Classes".  Have also searched for related posts.
    The pic below shows an invoke node wired to a class with a Public VI "VAT.Status.Hello.vi".  I'd like to see VAT.Status.Hello show-up as a Method.  (I just tried "Select Method", and selected "VAT.Status.Hello.vi" but dialog's "OK" button stays greyed-out.)
    Cheers.
    Message Edited by tbd on 03-29-2007 03:15 PM
    "Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)
    Attachments:
    VATStat.JPG ‏54 KB

    Hi Aristos,
          Thanks for the reply!  It was a bit dissappointing, though.
    It appears the LabVIEW-class object will be moving away from (what seems to me) a convenient object-interface presented by the invoke-node/method paradigm - which allows us to interface with a large set of "objects" (.NET, ActiveX, LabVIEW GUI, VISA Resource, ?) in a similar manner and independent of the object's origin.  Being able to read the methods and parameters that appear in these nodes is also helpful for understanding diagram logic!
    I do like the option of dropping a friendly "VI looking" icon on the diagram, but perhaps an optional - even default - VI-icon representation for a class-object invoke-node is feasible - so the LabVIEW class-object could be the more generic object first, but with a traditional-G representation(?)
    Given the answer "We would like, someday, to support the property node"
    and "in the next version of LV, wiring the LV class to the property/invoke nodes will break the wire so we'll avoid confusion in the future",
    ... I guess you'll break the wire in the next version, but (perhaps) allow it again - if support of the property node is ever implemented?
    Regards.
    P.S. For the record, huge THANKS to whoever it was that straightened-out enumerated-types (somewhere) between LV4.1 and LV6.1.  Every time I add or remove an enumeration in a typedef, I silently give thanks to the bright and thoughtful soul(s) who made this valuable tool work so well!
    Hello. This is your friendly neighborhood R&D guy for LabVIEW classes.
    Regarding your request about property and invoke nodes as relates to LV classes....
    Short story: We would like, someday, to support the property node. We have no intention of ever supporting the invoke node.
    Long story: As we were creating LV classes, we had to evaluate the right programming interface for these things. We wanted LV classes to behave as new data types in LV. A developer should be able to create a LV class, then give it to someone who doesn't even know OO programming, and that second programmer could use the new data type without learning a lot of new concepts. From this principle, we held fast to the idea that the programming interface should be subVI calls whereever possible. The invoke node is really nothing more than a VI minus the icon. If you want, you can popup on any subvi node and uncheck the option "View as Icon". This will make the node display in a way that has the terminals listed as text, like the invoke node. So, at the end of the day, the invoke node is simply a subroutine call in LV that is language dependent, as opposed to the language independent iconography of LV generally.
    The property node is a slightly different story -- the functionality of a property node is actually different than an invoke node as its terminals are various subsets of the properties available, not a fixed list of parameters like the invoke node. The property node provides a nice interface for setting multiple properties in a block and only having to check a single error return. Very friendly. Our intent is to allow you to create a VI that has 5 terminals: object in, object out, error in, error out, and either a single input or a single output of your chosen type. VIs with this conpane could be marked as "properties" of the class and would show up when you wire the class wire to the property node. We would call the subVIs behind the scenes as needed to get/set the properties.
    This is on the longer term roadmap because it is "syntactic sugar" -- it sweetens the programming style, but it is not necessary to program effectively. You can get the same effect by writing those same VIs and stringing them along on a block diagram "railroad track" style. We'll probably get around to it in three or four versions of LV -- there are some major user requests that impact functionality that have to get done first.
    PS -- in the next version of LV, wiring the LV class to the property/invoke nodes will break the wire so we'll avoid confusion in the future of people thinking there's a way to use these nodes.
    Message Edited by Aristos Queue on 04-02-2007 09:56 AM
    Message Edited by tbd on 04-03-2007 12:39 PM
    "Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)

  • What is the advantage of using IB to create XIBs/Class Objects over coding?

    Hi all,
    I hoping someone can provide me some pros and cons as to when I should use IB to create XIBs and/or class objects as opposed to directly coding them.
    For example, if I choose Apple's Template for creating a Navigation Based Application (cocoa touch), the project creates two NIB files - MainMenu and RootViewController.
    However looking at one of demo apps SimpleDrillDown, it does not have a RootViewController XIB and instead creates it via code.
    Another example from the same two apps is that the template generates a "Navigation Controller" class object in the Mainmenu.xib. SimpleDrillDown does not bother with this in the XIB, but uses code to generate the controller:
    - (void)applicationDidFinishLaunching:(UIApplication *)application {
    // Create the navigation and view controllers
    RootViewController *rootViewController = [[RootViewController alloc] init];
    UINavigationController *aNavigationController = [[UINavigationController alloc] initWithRootViewController:rootViewController];
    self.navigationController = aNavigationController;
    [aNavigationController release];
    [rootViewController release];
    // Configure and show the window
    [window addSubview:[navigationController view]];
    [window makeKeyAndVisible];
    as opposed to the template which only needs this:
    - (void)applicationDidFinishLaunching:(UIApplication *)application {
    // Configure and show the window
    // Navigation Controller is defined in MainWindow.xib
    [window addSubview:[navigationController view]];
    [window makeKeyAndVisible];
    So what are the advantages of each approach. Why does apple suggest one approach and yet all its demos use another.
    Any thoughts, answers gratefully received.
    TIA, Michael.

    You can do whatever you're comfortable with, but most of the best Cocoa programmers--the ones on the Mac, I mean--recommend putting everything you can into Interface Builder.
    It's a little like the difference between writing a program to do a bunch of financial calculations and using a spreadsheet. Yeah, the program can do everything the spreadsheet can--and more besides--but you'll find it far easier to create, use and modify the spreadsheet.
    Interface Builder takes away a lot of completely meaningless choices ("What order should I create the objects in? How should I name the variables? How should I create their frames? What order should I set the attributes in?"), leaving you with an interface optimized for creating and arranging objects, and allowing your code to focus on what you really do need to think about--your application's logic.
    (By the way--part of the reason Apple's demos don't all use Interface Builder is that the very first SDK releases didn't have it. Back then, you had to create all your views programatically. Believe me, I have no wish to go back to setting autoresize masks manually. Now get off my lawn, whippersnapper.)

Maybe you are looking for

  • Adding monitors to a laptop

    i just added an additonal monitor to my laptop and i need a second one to total three. They all need to be capable of showing different windows at the same time, is this possible? I dont have another VGA outlet on my laptop, is there an adapter. Also

  • Reading unicode file using pure C++??

    Hi Guys, I need help reading a unicode/utf8 file using C/C++. Any pointers or sample code will be of great help. Thanks Gulshan

  • Facebook's new ad tracking policy for user profiles.

    Facebook's newest policy seems quite invasive. I have my Mozilla Firefox browser set to "Tell sites that I do not want to be tracked." Is this sufficient to stop this new policy from Facebook or do I have to go through their options of using the Digi

  • Display Item Details in approval email

    Hi All, I would like to display 'Item Details' on the shopping cart approval email. Is there any standard program to achieve this. Please provide your inputs. System: SRM 5.0 Regards, Piyush

  • End with last image

    I need to export a sequence to a video that stops at the last image. Now the video switches back to the first image after playing in windows media player of quicktime. Is this an export preferences problem? How can I change this?