Getting an Array from a multi-dimentional Array within a Function

Don't know how to explain it but here, firstly, I can't get past. Also had this problem with another thing I was trying.
ReferenceError: Error #1056: Cannot create property 0 on Number.
I googled and found out about automatically declare stage instances, that was fine, I had the box checked.
Basically, it is failing at even the simplest. I have this function:
function getInfoOf(i) { // enemy count, info count
    var _info:Array = new Array(3, 6);
    // 0 is you
    _info[0,Const.MAXHP] = 500;
    _info[0,Const.CURRENTHP] = 500;
    _info[0,Const.LEVEL] = 5;
    _info[0,Const.EXP] = 5500;
    _info[0,Const.NAME] = "You";
    _info[0,Const.LINKEDMC] = "NONE";
    // then a few more _info's.
Then, trying everything to get it to work, I stripped it so no returns. So in the code, in the init() part of the project (only called once), have getInfoOf(0), and tried any other numbers. I recieve that error, and cannot for the life of me figure out whats wrong (I have also tested the "Const"'s. they are integers, and I have tested using numbers in  place of those. Still same error, it only goes away when I don't call the function at all.
Any help would be greatly appreciated.
Thanks.
Message was edited by: brokenhope
The array is actually (3,6), messed that up.

I don't know whats wrong here. I tried to get it to work on the project, still same exact error. So, I tried it on a entirely new project, and still get the exact same error. So I also put in a new function to test with no array.
stop();
function getInfoOf2():void {
    var blah = "testwat";
    trace(blah);
    return;
function getInfoOf():void {
    var info:Array=new Array(3);
    for(var i:int=0; i<info.length; i++) {
        info[i]=new Array(6);
    // 0
    info[0,0] = 500;
    info[0,1] = 500;
    info[0,2] = 5;
    info[0,3] = 5500;
    info[0,4] = 0;
    info[0,5] = 0;
    return;
this.getInfoOf2();
this.getInfoOf();
the function still fails, but the first function doesn't.
testwat
ReferenceError: Error #1056: Cannot create property 0 on Number.
    at Untitled_fla::MainTimeline/getInfoOf()
    at Untitled_fla::MainTimeline/frame1()
any ideas, I did a few traces, that message appears at the first info[0][0].
Thanks.

Similar Messages

  • Insert values in an array (within a function)

    Hello,
    I can't seem to get values insert in an array. I know it
    works outsite the function but
    when using variables in a function and trying to insert this
    in an array it does not work.
    The values are empty.
    But if you uncomment the line someArray.push(a0,a1,a2) and
    uncommend the for loop it works.
    In actionscript 2.0 i could use eval ..but in actionscript
    3.0 you have to use this to convert a string to a value.
    Does anyone see, what i am doing wrong?
    function doSomething() {
    var a0:String = "hello";
    var a1:String = "why doesn't it";
    var a2:String = "work!";
    var someArray:Array = new Array();
    //someArray.push(a0,a1,a2);
    for (var i:uint =0; i<=3; i++) {
    someArray.push(this["a"+i]);
    trace(someArray);
    doSomething();

    In this case, the problem arises from a scope issue. The vars
    are defined within the function so they are visible only within the
    function. When you use "this" you are referencing the object that
    contains the function, which cannot see those vars (they do not
    exist for "this", only for the function). It works if you go this
    way...
    var a0:String = "hello";
    var a1:String = "why doesn't it";
    var a2:String = "work!";
    function doSomething() {
    var someArray:Array = new Array();
    for (var i:uint=0; i<3; i++) {
    someArray.push(this["a"+i]);
    trace(someArray);
    doSomething();
    The other line: someArray.push(a0,a1,a2);
    does work because it is within the function and can see the
    vars.

  • Multi-dimentional array

    I have an multi dimentional array
    it has 5 columns and 8 rows
    A B C D E
    F G H I J
    K L M N O
    P Q R S T
    U V W X Y
    etc
    if i remove the row beginning [1][0]
    how can I get all the ones passed that row to shuffle up to fill the gap?
    A B C D E
    K L M N O
    P Q R S T
    U V W X Y
    ends up as
    A B C D E
    K L M N O
    P Q R S T
    U V W X Y
    Code would be lovely, I am new to this programming lark and I am not sure i like it :'(

    This is something done best (as previously suggested) with collections. Look into the tutorial and APIs for ArrayList and such. However, if you need to use arrays, here is a program that does (rather poorly I would think...)
    public class MultiArrayTest {
        public static void printData(char[][] data, int numRows, int numCols) {
             for (int r = 0; r < numRows; r++) {
                  for (int c = 0; c < numCols; c++){
                       System.out.print("" + data[r][c] + " ");
                  System.out.println(" ");
              System.out.println(" ");
        public static int deleteRow(char[][] data, int row, int maxRows, int maxCols) {
             for (int r = (row-1); r < (maxRows-1); r++){
                  for (int c = 0; c < maxCols; c++) {
                       data[r][c] = data[r+1][c];
             return maxRows-1;
         public static void main(String[] args) {
              char[][] data = { {'A', 'B', 'C', 'D', 'E'},
                                 {'F', 'G', 'H', 'I', 'J'},
                                 {'K', 'L', 'M', 'N', 'O'},
                                 {'P', 'Q', 'R', 'S', 'T'},
                                 {'U', 'V', 'W', 'X', 'Y'} };
              int maxRows = 5;
              int maxCols = 5;
              printData(data, maxRows, maxCols);
              maxRows = deleteRow(data,3,maxRows,maxCols);
              printData(data, maxRows, maxCols);
    }

  • How can i get a array from a JSP ?

    Hi all,
    i have a STORED PROCEDURE like this:
    static public void getMyArray(double [] xx) {
    for (int i=0; i<myarr.length;i++){
    myarr=3.145*i;
    xx=myarr;
    return ;
    how can i get the array with XSQL and transform with a XSL ?
    Is this at all possible?
    Thanks for any help.
    Achim

    u r asking how ca u get array from jsp?
    and u r asking xsql ...some stuff i couldnot understand .can u repeat the question properly?
    null

  • Get numerical values from 2D array of string

    Hello! 
    I start by saying that I have a base knowledge of LabView. I'm using LabView 2011. I'm doing some communications test via Can-Bus protocol. As you can see in pictures of the block diagram and of the front panel that I've attached I'm using "Transmit Receive same Port" LabView example. It works very good but I would need to insert the 8 data bytes that I receive from the server in 8 different numerical variables so that I could use them to make some operations. How can I get numerical values from the 2D array of string that I attached? 
    Every example that you can provide is important! 
    Thank you very much! 
    Attachments:
    1.jpg ‏69 KB
    2.jpg ‏149 KB

    Hi martiflix,
    ehm: to unbundle data from a cluster I would use the function Unbundle(ByName)…
    When you are new to LabVIEW you should take all the FREE online resources offered by NI on their website!
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • How to get byte array from jpg in resource for Image XObject?

    Hi,
    Does anyone know how to get an array of bytes from a jpg from resource without an external library except MFC?
    The array of bytes is needed to create an Image XObject so it can be included in an appearance for an annotation.

    Sounds like a standard Windows programming question, not specific to the SDK.

  • Getting an Array complex Type From a SOAPMessage using SAAJ

    My question is can you do that?
    I was able to put together a properly formatted message for a .NET SOAP service, send it, and get the response (without Fault), but from the response
    SOAPMessage response = connection.call(message, endpoint);
    I don't see how to get the array, and I can't find any example on the web any where using SAAJ. It's not an attachment, because
    System.out.println("Number of attachments.... " + response.countAttachments() );
    gives me
    Number of attachments.... 0.
    Has anybody seen an example on how to do this? I haven't seen any docs on this been looking for two days.      

    Hello,
    It sounds like you want to get the body of that response SOAP Message. If i'm right then you should review the structure of a SOAP Message, it is something like..
    <Message>
    <Envelope>
    <Header></Header>
    <Body></Body>
    </Envelope>
    </Message>
    That structure is basically a one without attachments. To get the body, SAAJ gives you a method (i don't quite recall it now) something like response. getEnvelope().getBody() and inside Body you should get the values you asked for.
    Nonetheless, i'm gonna give you a great resource web page address... Good Luck!!!
    http://java.sun.com/webservices/docs/1.3/tutorial/doc/index.html
    JJ2O Venezuela

  • Please help how to get return array from rpg program on java code?

    Hi
    I have created a rpg program that returns 2 parameter 1 is the id and another one is list of array, when I called this program I passed two programparameter from my java code (see the code below) but when i checked what value would be return it is returned only first value of array. how will i get all array values ?
    please suggest me regarding this issues I amn't so much aware on java & AS400.
    try
    ProgramParameter[] parmList = new ProgramParameter[2];
    AS400Text p1 = new AS400Text(10);
    AS400Text p2 = new AS400Text(30);
    try
    parmList[0] = new ProgramParameter(10);
    parmList[1] = new ProgramParameter(30);
    parmList[0].setParameterType(ProgramParameter.PASS_BY_REFEREN CE);
    parmList[1].setParameterType(ProgramParameter.PASS_BY_REFEREN CE);
    parmList[0].setInputData(p1.toBytes("Pune"));
    parmList[1].setInputData(p2.toBytes(" "));
    catch(Exception ex)
    ProgramCall pgm = new ProgramCall(o);
    pgm.setProgram("/QSYS.LIB/XXX/XXX.PGM",parmList);
    if (pgm.run())
    byte s[] = parmList[1].getOutputData(); // HERE I got only first value of returning array.
    parmList[1].getOutputDataLength();
    //String sts = ((String) (new AS400Text(10,o).toBytes(s[0])));
    else
    AS400Message[] messageList = pgm.getMessageList();
    for (int msg = 0; msg < messageList.length; msg++) {
    catch(Exception ex)
    AS400Message[] messageList = null;
    finally
    o.disconnectAllServices();
    Reply With Quote

    Try this :
    try
    ProgramParameter[] parmList = new ProgramParameter[2];
    AS400Text p1 = new AS400Text(10);
    AS400Text p2 = new AS400Text(30);
    AS400Array arrP2 = new AS400Array(p2, 4);
    try
    parmList[0] = new ProgramParameter(10);
    parmList[1] = new ProgramParameter(30);
    parmList[0].setParameterType(ProgramParameter.PASS_BY_REFEREN CE);
    parmList[1].setParameterType(ProgramParameter.PASS_BY_REFEREN CE);
    parmList[0].setInputData(p1.toBytes("Pune"));
    parmList[1].setInputData(arrP2.toBytes({"","","",""}));
    catch(Exception ex)
    ProgramCall pgm = new ProgramCall(o);
    pgm.setProgram("/QSYS.LIB/XXX/XXX.PGM",parmList);
    if (pgm.run())
         Object[] objArr =  (Object [])arrP2.toObject( parmList[1].getOutputData() );
         for(int i =0; i<objArr.length;i++){
                System.out.println( " SKU " + i +" : " + objArr.toString());
    else
    AS400Message[] messageList = pgm.getMessageList();
    for (int msg = 0; msg < messageList.length; msg++) {
    catch(Exception ex)
    AS400Message[] messageList = null;
    finally
    o.disconnectAllServices();

  • Is there any way to get an array from an object?

    public class X {
    byte[] a = new byte[] {0x10,0x20};
    //Native method
    public native short testnative(X b);
    //C++
    JNIEXPORT jshort JNICALL Java_Native_testnative1 (JNIEnv *env , jobject obj, jobject testobj)
    Is there any way to get byte[] a from jobject testobj ?
    Pprimitive types and objects can be get by JNI functions(like GetIntField, GetObjectField etc.), but I didn't find fucntions like GetXXXArrayField(), then how can I do that?

    Hint: an array is an object.
    -slj-

  • Can't get an array of characters from a string!

    If I have a string eg "Hello World", how do I get an array containing the characters eg. [H,e,l,l,o, ,W,o,r,l,d]
    Can any one help me please?

    Or to get the chars you want from a String object you can do this:
    String helloString = new String("Hello World");
    char[] helloArray = helloString.toCharArray();

  • How to get An Array from PostgreSQL.

    When I design a programm to get an array object from a postgreSQL database, the programm give the following exception:
    "This method is not yet implemented"
    Who can help me?
    Thanks!!!!
    Here are my codes:
    import java.sql.*;
    class test {
    public static void main(String args[]) {
    String url = "jdbc:postgresql://localhost:5432/testdb";
    String query = "select * from table1";
    try {
    Class.forName("org.postgresql.Driver");
    Connection con = DriverManager.getConnection(url,"aa", "bb");
    Statement stmt = con.createStatement();
    ResultSet rs = stmt.executeQuery(queryStr);
    while(rs.next()) {
         Array array = rs.getArray("idnum");
    } catch(Exception ex) {
    System.out.println("Get Data Fail: " + ex);
    the table struct of "table1"
    =============================
    varchar(10) int4[]
    name | idnum
    -----------------+--------------------------------
    Bill | {100430,134630000,10000,10000}

    You pass a string to the getArray method. The parameter should be an integer, representing the desired column.

  • Initialize a multi-dimentional array at declaration

    Is there any way I can initialize a multi-dimentional array at declaration.
    Is it possible to do the following in a single line?
               Vector vClicks[] = new Vector[2];
                vCliks[0] = new Vector();
                vClicks[1] = new Vector();I need to globally initialize it and then used it randomly in different methods.
    Thanks
    Message was edited by:
    getusama

    Is there any way I can initialize a multi-dimentional
    array at declaration.
    Is it possible to do the following in a single line?
    Vector vClicks[] = new Vector[2];
    vCliks[0] = new Vector();
    vClicks[1] = new Vector();
    I need to globally initialize it and then used it
    randomly in different methods.
    Thanks
    Message was edited by:
    getusama
    Vector [] v = {new Vector(), new Vector()};~Tim
    Message was edited by:
    SomeoneElse

  • How i can get a array in the current page?

    Can i send a array parameters from previous page to current page?
    the coding like below:
    // the coding in the previous page
    String[] strSend = {"a", "b", "c"};
    HashMap map = new HashMap(2);
    map.put("array", strSend);
    pageContext.setForwardURL(
    "OA.jsp?OAFunc=XXFMSRHISQF",
    null,
    KEEP_MENU_CONTEXT,
    null,
    map,
    true,
    ADD_BREAD_CRUMB_NO,
    IGNORE_MESSAGES );
    //the coding in the processRequest of the current pageCO.
    String strParam = pageContext.getParameter("array");
    the problem is that the type of "strParam" is a String.
    it's not a array of String. So it is not the parameter what i need.
    can u tell me how to get the array parameter from previous page. thanks.

    This cannot be achieved directly while using the setForwardURL method, all values that are there in the Hashmap will be appended when the redirection is done, so you cannot get the values that are there in the array object directly.
    Workaround that I can think of, put all the array values in a String object, appended by a delimiter, in the second page, after you do a getParameter(String), recover the values using a StringTokenizer and the delimiter that you used while appending the string values and store the values in a Array.
    Thanks
    Tapash

  • When I get an ICS from Outlook that is a multi-day event it populates my iCal as a single day and since I am not the owner I cannot edit the ICS.

    When I get an ICS from Outlook Express (Office is PC based) that is a multi-day event, it populates my iCal as a single day and since I am not the owner I cannot edit the ICS. I have to delete it and send a "decline notice" to the sender and re-enter it so I can put in multiple day events. Help!

    If you are running Tiger, you don't have time machine. 
    You need to get something like SuperDuper! or Carbon Copy Cloner (sorry, I don't have a handy link for CCC but you can Google it to get their site) to make a clone of your drive on the external and then do incremental backups.  The free versions do a lot and you can upgrade to the full-service versions for small change if you need more.  The one time I used SuperDuper! for cloning a volume it worked just fine. 
    (My backup application is the last PPC capable version of Retrospect, which does a credible job, or has over the past ten-twelve years.)

  • How to get an array variable to update in a loop

    Hi
    I have an array of doubles called cps that contains a double h.
    the array is defined out of the loop.
    The loop defines the value of h and uses that array to do something. How can I get the array to update h at every iteration of the loop?
    // STAR-CCM+ macro: test.java
    package macro;
    import java.util.*;
    import star.common.*;
    import star.base.neo.*;
    import star.vis.*;
    import star.base.report.*;
    public class test extends StarMacro {
    public void execute() {
    double h ;
    int i;
    double[] cps= new double[] {75.9042408986955, 52.51153872409542, h, 76.51180919240942, 49.49901260109725, h, 77.70163043426585, 49.67622002009714, h, 78.35982941912259, 46.537117169241895, h, 78.08136061783705, 45.42324196409971, h, 75.67640278855279, 44.840989015957206, h, 68.73999810198555, 40.942425797959565, h, 66.66413976512966, 44.511889523528836, h, 67.85396100698608, 44.99288108938568, h, 68.81594413869979, 45.65108007424243, h, 69.37288174127089, 46.081440948956455, h, 68.99315155769969, 46.992793389527336, h, 68.38558326398577, 48.005407212383865, h, 67.8792763525575, 48.81549827066909, h, 73.423337032697, 51.954601121524334, h};//coordinates of constrained section plane
    Simulation simulation_0 =
    getActiveSimulation();
    // CREATING CONSTRAINED PLANE SECTIONS //
    Region region_0 =
    simulation_0.getRegionManager().getRegion("main domain;main domain;NONE");
    Units units_0 =
    ((Units) simulation_0.getUnitsManager().getObject("m"));
    i = 0;
    for ( h = 0.5; h <= 2; h = h + 0.5) {
    i = i + 1;
    ConstrainedPlaneSection constrainedPlaneSection_i =
    (ConstrainedPlaneSection) simulation_0.getPartManager().createConstrainedPlaneImplicitPart(new NeoObjectVector(new Object[] {region_0}), new DoubleVector( cps ), units_0); // Sets Plane Boundaries (as mapped) //
    LabCoordinateSystem labCoordinateSystem_0 =
    ((LabCoordinateSystem) simulation_0.getCoordinateSystemManager().getObject("Laboratory")); // Defines Lab Coordinate System (Does this once). //
    constrainedPlaneSection_i.setCoordinateSystem(labCoordinateSystem_0); // Sets this planes coordinate system //
    Coordinate coordinate_i =
    constrainedPlaneSection_i.getOriginCoordinate();
    coordinate_i.setCoordinate(units_0, units_0, units_0, new DoubleVector(new double[] {71.92329015, 46.4835809, 0.5})); // Sets the origin for the plane //
    constrainedPlaneSection_i.setPresentationName("Unit 1 " + h + "m");
    }

    double h ;
    double[] cps= new double[] {75.9, 52.5, h, 76.5, 49.4, h,  // simplifiedLooking at your code I see that you have initialised your array with the value of the variable h scattered throughout it. Are you asking how you can update these "h" values in the array each time around the loop? eg:
    Initial array: 75.9, 52.5, 0.0, 76.5, 49.4, 0.0
    1st iteration: 75.9, 52.5, 999.999, 76.5, 49.4, 0.0
    2nd iteration: 75.9, 52.5, 999.999, 76.5, 49.4, 999.999
    Something like that.
    If so then you need to know what the indicies of the numbers you want to update which may not be a simple matter. Perhaps an array is not what you want here but maybe a Map instead.

Maybe you are looking for

  • Xperia T- Bluetooth Issues since Andriod 4.3 Upgrade.

    Hello All. Since my phone was upgraded to Andriod 4.3 Jelly bean, I've been unable to make calls from my phone via my BMW car audio as before, as the Bluetooth link keeps dropping out. I've tried re- pairing the phone to my car, but this has made no

  • Photoshop CC quits after launching (Mac)

    Hello! I have the same problems that others have reported, but I have not seen a definite fix posted. Problem: Just installed Photoshop CC on a Mac running OS X Mavericks 10.9.3 -- when the app is launched, the splash screen is displayed, then Photos

  • Java style and coding conventions

    Hello All, Most of my programming experience is in Java, and as such, I try to conform to the style and coding conventions that are used in all of the Sun tutorials, and to my understanding, the specification. I'm enrolled in my final semester of a b

  • PS CC slow down after imported preferences/preset.

    Hello! Since I have imported all the preferences/preset from PS CS6 to PS CC, when I open Photoshop CC - on reading preferences - the program stops for about a minute. The only think I can suppose is about actions. I have a lot of actions loaded. I h

  • Still no news on how to disable the sender's ID on the notification banner in locked screen?

    Still looking for some more help on this, since I've got no answer from Apple yet. Maybe never gave it a thought, although all my friends complain about the same thing... I'll say it again, it is annoying to have the 3rd party ID on plain sight: my c