Problem shifting (copying) array elements in a list

I am trying to add points to the beginning of a list. However, I cannot seem to debug the insertBeginning( ) method. I am faced with a problem that overwrites certain array elements. If I can get any help I would greatly appreciate it.
Thanks,
I have included a sample run and some code.
The following url contains both the main and the class files.
http://lbbmx.com/java/
public void appendZ ( Point newPoint ) // used w/ insertBeg method
     size++;
     cursor=0;
     ptlist[cursor]= newPoint;
public void insertBeginning ( Point newPoint )      // Insert begin.
          if(this.isEmpty())
            {append(newPoint);}
         else
          cursor=0;
          for(int i=size; i>cursor; i--)
              ptlist[size]= ptlist[size-1];   //pt[1]=pt[0]
          this.appendZ(newPoint);Here is a sample run:
Commands:
  + x y  : Append point (x,y) to the end of the list
   # x y  : Insert point (x,y) at beginning
   Q      : Quit the test program
Empty list
Command: +1 1
Append (1,1)
size = 1   cursor = 0
0     1     2     3     4     5     6     7     
(1,1)     
Command: #2 2
Insert (2,2) at beginning
size = 2   cursor = 0
0     1     2     3     4     5     6     7     
(2,2)     (1,1)     
Command: #3 3
Insert (3,3) at beginning
size = 3   cursor = 0
0     1     2     3     4     5     6     7     
(3,3)     (1,1)     (1,1)     

ptlist[size]= ptlist[size-1];In this situation, size is the variable you are keeping track of how many elements are in your array. This does not change until after you have inserted the new Point. So, regardless of how many times you go around the loop you are simply copy the same value.
"How do I fix it?" I hear you ask.
Well what changes everytime you go around the loop?

Similar Messages

  • Problem including new array element

    I?m new to java programmning so that certainly the problem i?m facing is easy to resolve to most of people here.
    I have an array with 6 elements for example:
    String [] a = {"1","2","3","4","5","6"};
    and i want to include one last element inside of this array. Its supposed to be simple but i only get and exception that the array out of bound.
    I tried everything i know so i would need some help
    Thanks in advance
    odik

    Arrays are immutable meaning you can't add to them once they are created. You should use an ArrayList or Vector to hold your data if you are unsure of the size. If you need to convert the data to an array, you can do something like the following:
    List list = new ArrayList();
    list.add("1");
    list.add("2");
    list.add("6");
    list.add("7");
    String s[] = (String[])list.toArray(new String[list.size()]);

  • A basic question/problem with array element as undefined

    Hello everybody,
    thank you for looking at my problem. I'm very new to scripting and javaScript and I've encountered a strange problem. I'm always trying to solve all my problem myself, with documentation (it help to learn) or in the last instance with help of google. But in this case I am stuck. I'm sure its something very simple and elementary.
    Here I have a code which simply loads a text file (txt), loads the content of the file in to a "var content". This text file contents a font family name, each name on a separate line, like:
    Albertus
    Antenna
    Antique
    Arial
    Arimo
    Avant
    Barber1
    Barber2
    Barber3
    Barber4
    Birch
    Blackoak ...etc
    Now, I loop trough the content variable, extract each letter and add it to the "fontList[i]" array. If the character is a line break the fontList[i] array adds another element (i = i + 1); That's how I separate every single name into its own array element;
    The problem which I am having is, when I loop trough the fontList array and $.writeln(fontList[i]) the result in the console is:
    undefinedAlbertus
    undefinedAntenna
    undefinedAntique
    undefinedArial ...etc.
    I seriously don't get it, where the undefined is coming from? As far as I have tested each digit being added into the array element, I can't see anything out of ordinary.
    Here is my code:
    #target illustrator
    var doc = app.documents.add();
    //open file
    var myFile = new File ("c:/ScriptFiles/installedFonts-Families.txt");
    var openFile = myFile.open("r");
    //check if open
    if(openFile == true){
        $.writeln("The file has loaded")}
    else {$.writeln("The file did not load, check the name or the path");}
    //load the file content into a variable
    var content = myFile.read();
    myFile.close();
    var ch;
    var x = 0;
    var fontList = [];
    for (var i = 0; i < content.length; i++) {
        ch = content.charAt (i);
            if((ch) !== (String.fromCharCode(10))) {
                fontList[x] += ch;
            else {
                x ++;
    for ( i = 0; i < fontList.length; i++) {
       $.writeln(fontList[i]);
    doc.close (SaveOptions.DONOTSAVECHANGES);
    Thank you for any help or explanation. If you have any advice on how to improve my practices or any hint, please feel free to say. Thank you

    CarlosCantos wrote an amazing script a while back (2013) that may help you in your endeavor. Below is his code, I had nothing to do with this other then give him praise and I hope it doesn't offend him since it was pasted on the forums here.
    This has helped me do something similar to what your doing.
    Thanks again CarlosCanto
    // script.name = fontList.jsx;
    // script.description = creates a document and makes a list of all fonts seen by Illustrator;
    // script.requirements = none; // runs on CS4 and newer;
    // script.parent = CarlosCanto // 02/17/2013;
    // script.elegant = false;
    #target illustrator
    var edgeSpacing = 10;
    var columnSpacing = 195;
    var docPreset = new DocumentPreset;
    docPreset.width = 800;
    docPreset.height = 600;
    var idoc = documents.addDocument(DocumentColorSpace.CMYK, docPreset);
    var x = edgeSpacing;
    var yyy = (idoc.height - edgeSpacing);
    var fontCount = textFonts.length;
    var col = 1;
    var ABcount = 1;
    for(var i=0; i<fontCount; i++) {
        sFontName = textFonts[i].name;
        var itext = idoc.textFrames.add();
        itext.textRange.characterAttributes.size = 12;
        itext.contents = sFontName;
        //$.writeln(yyy);
        itext.top = yyy;
        itext.left = x;
        itext.textRange.characterAttributes.textFont = textFonts.getByName(textFonts[i].name);
        // check wether the text frame will go off the bottom edge of the document
        if( (yyy-=(itext.height)) <= 20 ) {
            yyy = (idoc.height - edgeSpacing);
            x += columnSpacing;
            col++;
            if (col>4) {
                var ab = idoc.artboards[ABcount-1].artboardRect;
                var abtop = ab[1];
                var ableft = ab[0];
                var abright = ab[2];
                var abbottom = ab[3];
                var ntop = abtop;
                var nleft = abright+edgeSpacing;
                var nbottom = abbottom;
                var nright = abright-ableft+nleft;
                var abRect = [nleft, ntop, nright, nbottom];
                var newAb = idoc.artboards.add(abRect);
                x = nleft+edgeSpacing;
                ABcount++;
                col=1;
        //else yyy-=(itext.height);

  • How to copy an array element in one class to an array in another class?

    Hi,
    I have a ClassRoom class that stores a list of Student objects in an array. How would I copy a Student object from the Student[] array in the ClassRoom class to an array in another class?
    Is it something like this:
    System.arraycopy(Students, 2, AnotherClass.Array, 0, 2);In an array do the items get copied over existing array elements or can the be added to the end? If so, how would I specify add copied object reference to the end of the array in the other class?

    drew22299 wrote:
    Hi,
    I have a ClassRoom class that stores a list of Student objects in an array. How would I copy a Student object from the Student[] array in the ClassRoom class to an array in another class?
    Is it something like this:
    System.arraycopy(Students, 2, AnotherClass.Array, 0, 2);In an array do the items get copied over existing array elements or can the be added to the end? If so, how would I specify add copied object reference to the end of the array in the other class?System.arrayCopy will overwrite whatever is already in the array. It is your job to make sure it copies into the proper array location.
    That being said, you're only moving a single student. This is not something you would use arrayCopy for, as you can just do that with simple assignment. Also, you should consider giving Class a method to add a student to its student list, as the class should know how many students it has and can easily "append" to the array.
    Note: I hope you noticed the quotes around append. Java's arrays are fixed size. Once allocated, their size cannot change. You may want to consider using one of the List implementations (ArrayList, for example) instead.

  • Java 1.5 - Each Element of a List Cannot Be An Array?

    I plan to create a List and each element of this List is a String Array.
    First, I declared a List:
         private static List<String> recursiveTextArray = new ArrayList<String>();And I want to build this List by adding one Array at a time:
    recursiveTextArray.add( title );where
    private String[] title;
    title = new Array(3);I got syntax error saying: "The method add(String) in the type List<String> is not applicable for the arguments (String[]).
    I cannot figure out what the compiler is complaining about. How do I fix the problem? Thanks in advance.

    I think that I have some idea about what is going on. Because Array is an object, I should:
    private static List<Object> recursiveTextArray = new ArrayList<Object>();But the Java statement shown right above has a syntax error: "Syntax error on token ";", , expected"
    I have no clue why there is such a syntax error.

  • Problem in assigning value to an array element

    hi all
    in the following prog i am not able to assign the value to the array element
    i am not getting why it is giving me error
    //my program is as follows
    public class ArrayTest
         static int [] intArray = new int[5];
         static int [] intArray1 = new int[1];
         intArray1[0] = 5; // this line gives error
         static char [] charArray = new char[5];
         public static void main(String args[])
              System.out.println(charArray);
              intArray1 = intArray;
    }thanx in advance as usual

    The problem is that you try to execute code outside a method. This can be only done in form of a variable declaration or as a static initilization block which will be executed once when the class is loaded:public class ArrayTest
         static int [] intArray = new int[5];
         static int [] intArray1 = new int[1];
         static char [] charArray = new char[5];
         static {
              intArray[0] = 5;
         public static void main(String args[])
              System.out.println(charArray);
              intArray1 = intArray;
    }

  • Copy vector elements to array

    if i create a vector called aList,
    and it had 2 elements "peter" and "june"
    and i create a new array >>String[] name = new String[5];
    how to use this method
    copyInto(Object[] anArray)
    Copies the components of this vector into the specified array.
    to copy the 2 elements in aList vector to my name[1]?

    if i create a vector called aList,
    and it had 2 elements "peter" and "june"
    and i create a new array >>String[] name = new
    String[5];
    how to use this method
    copyInto(Object[] anArray)
    Copies the components of this vector into
    ctor into the specified array.
    to copy the 2 elements in aList vector to my name[1]?A confusing question: you want to put two Vector elements into one array element? Can't put ten pounds of @%^@%^@^ in a five pound bag, can you?
    If you really want two Vector elements to be stored in one array element you'll have to combine them in some way. String concatenation will do.
    If you mean you'd like to copy all the Vector elements into the array, you'll have to do something like this:
    Vector aList = new Vector();
    // add some elements to aList
    int numNames = aList.size();
    String [] names = new String[numNames];
    for (int i = 0; i < numNames; ++i)
       names[i] = (String)aList.get(i);MOD

  • Problems with synchronizing an element in an array

    I have a class that extends ArrayList. I have another class called "Elem" that works as elements for the ArrayList. Multiple threads will work on this list.
    When I get an element from the ArrayList I would like to lock only this element so another thread can delete other elements in the list.
    I have made this method for getting and locking an element:
         public String get(int id)
              String res ="No such file, try command list";
              int size = this.size();
              for (int i = 0; i<size;i++)
                   Elem ifo = (Elem)this.get(i);
                   if(ifo.getId() == id)
                        synchronized(ifo)
                             try {
                                  Thread.sleep(4000);
                             } catch (InterruptedException e) {
                                  e.printStackTrace();
                             res = ifo.getData() + " Received";
                        break;
              return res;
         }I have made the operation last for 4 seconds because I test if the object is locked with the follwing delete method:
         public synchronized String del(int id)
              String res =" no file";
              int size = this.size();
              for (int i = 0; i<size;i++)
                   Elem ifo = (Elem)this.get(i);
                   if(ifo.getId() == id)
                        super.remove(ifo);
                        res = ifo.getId() + " deleted!";
                        break;
              return res;
         }But when I run the program and start reading an element that I try to delete at the same time it gets deleted! Why does the "del" method not block until the element has been read?

    Ok here is what I am trying to do.
    1) Thread 1 get an element from list A. At the SAME
    time thread 2 deletes a different element from list
    A.Everything I've said still applies. What do you mean "at the SAME time"? And why does it have to be "at the SAME time"? What if whatever triggers cause the two actions happen "at the SAME time," but the actual actions happen a millisecond apart?
    currently only serial execution works, since all the
    methods on the list are synchronized.Again, anytime you're accessing shared data from multiple threads, you must synchronize. That syncing may be very, very brief--say just to atomically update a counter or "available" bitmap or something, but if there's shared data--such as a bitmap that keeps track of which slots are used--read/updates, like "find an available one, mark it used, and give me its index"--must be atomic, so there must be some synchronization.
    Or else different threads get different sections of the array assigned to them.

  • Can't download my purchased copy of Elements 12

    I purchased Photoshop Elements 12 on Dec 23, 2013. Adobe later offered an update to version 12.1.  I installed the update.
    I just bought a new computer running Windows 7, and I would like to download and install the Photoshop Elements that I had purchased.
    According to the Help in Photoshop Elements 12, I had to uninstall Photoshop Elements 12 on my old computer.  I did this.  During the uninstall a check box is supposed to appear that says something like "Deactivate product".  No such checkbox appeared during the uninstall.
    I have signed in to my account on the Adobe website several times.  It lists my purchased copy of Elements 12 but will not allow me to download it to my new computer.
    Not only will Adobe not allow phone tech support for Elements 12 owners, but they won't allow me to computer chat with support.
    Is there any way to contact Adobe support?
    How can I download and install my purchased copy of Photoshop Elements 12 onto my new computer?

    Deactivate is for PSE11 and earlier. In PSE12 you use the Help> Sign Out menu. There should be nothing to stop you downloading the software as many times as you want, maybe it is a problem with the servers. Instead of downloading from your 'My Adobe A/c' download the trial instead - it is identical.
    http://www.adobe.com/cfusion/tdrc/index.cfm?product=photoshop_elements&loc=en
    PSE12 allows you to install on as many computers as you have -  even dozens or hundreds. but only two can ever be signed in and activated at any one time.
    Cheers,
    Neale
    Insanity is hereditary, you get it from your children
    If this post or another user's post resolves the original issue, please mark the posts as correct and/or helpful accordingly. This helps other users with similar trouble get answers to their questions quicker. Thanks.

  • Deleting array elements

    Hi!
    I have a problem with my program. i have an array and in this array a several numbers. With the "In Range and Coerce" function i want to prove if the the array element is inside or outside of my limitations. If my array element is in the outside of my limitation, the code in the case structure should delete this element.
    I need this program, because the array is displayed on a graph and i want only display the date, which is in the limitations.
    I hope somebody could help me!
    Best regards,
    Peter
    Labview 7.1 on Windows 2000
    Attachments:
    array.jpg ‏54 KB

    Hallo Peter
    Das Problem tritt auf, weil du immer wieder das selbe Array liest.
    Die Knoten am Loop sollten Shift-Register sein, damit das Array, bei dem das Element gelöscht wurde, bei der nächsten Iteration gelesen wird. Allerdings musst du dann auf einen While-Loop umstellen, da du ansonsten Elemente lesen willst, die es im Array nicht mehr gibt.
    Anbei eine mögliche Lösung.
    Hoffe es hilft weiter.
    Thomas
    Using LV8.0
    Don't be afraid to rate a good answer...
    Attachments:
    RemoveElements.vi ‏32 KB

  • Accessing a user array elements in Captivate 6

    Hi guys I have a piece of code that's not working I was hoping someone had any clue as to why, I've wasted too many hours trying to figure this out.  Here's the code, explanation below.
    var objCP = document.Captivate;
    objCP.cpEISetValue("m_VarHandle.questionList", new Array(7));
    objCP.cpEISetValue("m_VarHandle.questionList[0]", 1);
    objCP.cpEISetValue("m_VarHandle.questionList[1]", 2);
    objCP.cpEISetValue("m_VarHandle.questionList[2]", 1);
    objCP.cpEISetValue("m_VarHandle.questionList[3]", 2);
    objCP.cpEISetValue("m_VarHandle.questionList[4]", 1);
    objCP.cpEISetValue("m_VarHandle.questionList[5]", 2);
    var cat1Len = 0;
    var cat2Len = 0;
    for (var i=0;i<objCP.cpEIGetValue("m_VarHandle.questionList.length");i++){
    var value = objCP.cpEIGetValue("m_VarHandle.questionList[i]");
    if (value == 1)
       {cat1Len++;}
    if (value) == 2)
       {cat2Len++;}
    alert(i);
    alert(objCP.cpEIGetValue("m_VarHandle.questionList[2]"));
    alert(value);
    I'm attempting to create a list using a captivate variable I've created called "questionList".
    I fill questionList with data and and then use that data to count, in this instance with cat1Len and cat2Len.
    After that I attempt to verify that the data is being returned correctly with a series of alerts.
    Here's the problem:
    alert(i) correctly reports the number my incrementer should be at.
    alert(objCP.cpEIGetValue("m_VarHandle.questionList[2]")) correctly reports the data in cell [2] of questionList
    but...
    alert(value) reports undefined.  How can this be? I know that I can access array elements from inside this loop and I know that I my incrementer is at the correct location so what's the deal?
    Thanks for any help!

    should be:
    var objCP = document.Captivate;
    objCP.cpEISetValue("m_VarHandle.questionList", new Array(7));
    objCP.cpEISetValue("m_VarHandle.questionList[0]", 1);
    objCP.cpEISetValue("m_VarHandle.questionList[1]", 2);
    objCP.cpEISetValue("m_VarHandle.questionList[2]", 1);
    objCP.cpEISetValue("m_VarHandle.questionList[3]", 2);
    objCP.cpEISetValue("m_VarHandle.questionList[4]", 1);
    objCP.cpEISetValue("m_VarHandle.questionList[5]", 2);
    var cat1Len = 0;
    var cat2Len = 0;
    for (var i=0;i<objCP.cpEIGetValue("m_VarHandle.questionList.length");i++){
    var value = objCP.cpEIGetValue("m_VarHandle.questionList["+i+"]");
    if (value == 1)
       {cat1Len++;}
    if (value) == 2)
       {cat2Len++;}
    alert(i);
    alert(objCP.cpEIGetValue("m_VarHandle.questionList[2]"));
    alert(value);
    i is only defined local to the javascript eval, not a global variable.  You have to pass the value, not the name of the index...
    (I just realized that this question was from 2012, but maybe it might still benefit someone...  I saw it while I was looking for something else)

  • Retrieve captivate array elements in Captivate 6

    Hi guys I have a piece of code that's not working I was hoping someone had any clue as to why, I've wasted too many hours trying to figure this out.  Here's the code, explanation below.
    var objCP = document.Captivate;
    objCP.cpEISetValue("m_VarHandle.questionList", new Array(7));
    objCP.cpEISetValue("m_VarHandle.questionList[0]", 1);
    objCP.cpEISetValue("m_VarHandle.questionList[1]", 2);
    objCP.cpEISetValue("m_VarHandle.questionList[2]", 1);
    objCP.cpEISetValue("m_VarHandle.questionList[3]", 2);
    objCP.cpEISetValue("m_VarHandle.questionList[4]", 1);
    objCP.cpEISetValue("m_VarHandle.questionList[5]", 2);
    var cat1Len = 0;
    var cat2Len = 0;
    for (var i=0;i<objCP.cpEIGetValue("m_VarHandle.questionList.length");i++){
    var value = objCP.cpEIGetValue("m_VarHandle.questionList[i]");
    if (value == 1)
       {cat1Len++;}
    if (value) == 2)
       {cat2Len++;}
    alert(i);
    alert(objCP.cpEIGetValue("m_VarHandle.questionList[2]"));
    alert(value);
    I'm attempting to create a list using a captivate variable I've created called "questionList".
    I fill questionList with data and and then use that data to count, in this instance with cat1Len and cat2Len.
    After that I attempt to verify that the data is being returned correctly with a series of alerts.
    Here's the problem:
    alert(i) correctly reports the number my incrementer should be at.
    alert(objCP.cpEIGetValue("m_VarHandle.questionList[2]")) correctly reports the data in cell [2] of questionList
    but...
    alert(value) reports undefined.  How can this be? I know that I can access array elements from inside this loop and I know that I my incrementer is at the correct location so what's the deal?
    Thanks for any help!

    should be:
    var objCP = document.Captivate;
    objCP.cpEISetValue("m_VarHandle.questionList", new Array(7));
    objCP.cpEISetValue("m_VarHandle.questionList[0]", 1);
    objCP.cpEISetValue("m_VarHandle.questionList[1]", 2);
    objCP.cpEISetValue("m_VarHandle.questionList[2]", 1);
    objCP.cpEISetValue("m_VarHandle.questionList[3]", 2);
    objCP.cpEISetValue("m_VarHandle.questionList[4]", 1);
    objCP.cpEISetValue("m_VarHandle.questionList[5]", 2);
    var cat1Len = 0;
    var cat2Len = 0;
    for (var i=0;i<objCP.cpEIGetValue("m_VarHandle.questionList.length");i++){
    var value = objCP.cpEIGetValue("m_VarHandle.questionList["+i+"]");
    if (value == 1)
       {cat1Len++;}
    if (value) == 2)
       {cat2Len++;}
    alert(i);
    alert(objCP.cpEIGetValue("m_VarHandle.questionList[2]"));
    alert(value);
    i is only defined local to the javascript eval, not a global variable.  You have to pass the value, not the name of the index...
    (I just realized that this question was from 2012, but maybe it might still benefit someone...  I saw it while I was looking for something else)

  • Problems defining the array for quicksort

    import java.io.*;
    import java.util.*;
    import chn.util.*;
    public class Store
              private Item [] myStore;
              public Store (String fileName) {
                   fileName = "file50.txt";
    /*          public void displayStore ()       
              public String toString () { }
              public void doSort () { }
    */          private void quickSort (Item[] lit, int lo, int hi)   // I don't exactly know what Item[ ] lit will do. please explain it for me.
              int h, l, p, t;
            if (lo < hi) { 
                l = lo;
                h = hi;
          /*      p = a[hi];     //my problem starts with the array 'a' (suppose to be item, but don't know how to modify that.
                do {
                    while ((l < h) && (a[l] <= p)) l++;
                    while ((h > l) && (a[h] >= p)) h--;
                    if (l < h) {
                        t = a[l];
                        a[l] = a[h];
                        a[h] = t;
                } while (l < h);
                t = a[l];
                a[l] = a[hi];
                a[hi] = t;
              private void loadFile (String inFileName)
                   FileInput inFile = new FileInput (inFileName = "file50.txt");
    }The array 'a' should be replaced with the array 'Item' but some how I'm getting the errors that Item's not a valid type.
    for more information, please see http://forum.java.sun.com/thread.jspa?threadID=699397&tstart=60 for more information (the original problem)

    Here is what I suggest.
    Use collections. I suggest an ArrayList. Using one array involves all sort of messy swapping around which really will make things difficult for you to grasp the basic concept of.
    So let us assume a method like this
    public void quicksort(List items)
    items is a List of Items.
    So here is how to write a quicksort
    1) If the size of the list is 1 then return the list because it is down to it's final piece and doesn't need to be sorted further
    2) Choose a pivot element of your list. The mid point is often chosen for this.
    3) Create two new Lists. One for lower elements and one for higher and equal to elements.
    4) Go through the list and use compareTo to compare the elements of the list with your pivot element. Take care to skip the pivot element. If elements are less than the pivot put them in the first list. If they are more than or equal to put them in the second list.
    5) Recursively call quicksort(list) on the sublists we made.
    6) Merge the sublists and pivot values back into one list
    7) return the merged list

  • Problem with building array inside a case statement

    I have a problem with my build array.
    Iam trying to construct a build array when ever I see a new element in my parent array during run time.
    Using shift registers, search array and If- case structure, inside a while loop. Iam implementing this logic (I dont want to use Event structure).
    Iam able to achieve most part of it, but have a problem with the first element. Except the first element of my parrent array, every thing is appending in to the build array. Can any one look at my vi and suggest me what Iam doing wrong here.
    Thank you
    Attachments:
    debug.vi ‏12 KB

    I think you need to replace the tunnels (carrying the array) in the for loop with a shift register.
    Lynn

  • Seek and destroy unknown array elements

    Hi, I'm looking for a way to determine if my array contains a specific element (without knowing what position number it is in the array)based on it's content, and then splices/deletes it.
    I found this from kirupa:
    Array.prototype.contains = function(input){
            for (var i in this) {
                    if (this[i] == input) {
                            return 1;
    return 0;
    //usage
    myArray.contains("value");
    and figure I could use something like it with
    myArray.splice(target,1);
    the only problem I'm seeing is getting "target" in the splice command to equal the "input" in the myArray.contains(); function.
    I originally needed this because I'm trying to add elements with prerequisites or associations intact, and subsequently when deleting the prerequsite for several other elements, those elements would also be deleted.

    last night/1am this morning before passing out I wrote this demo up to test if the idea was even going to work.
    Array.prototype.getIndex = function(data) {
        for (i=0; i<this.length; ++i) {
            if (this[i] == data) {
                return i;
        return -1;
    var afruit:Array = new Array(3);
    afruit[0] = "apple";
    afruit[1] = " orange";
    afruit[2] = "banana";
    swap = 0;
    onEnterFrame = function(){
    fruit.text = afruit.toString();
    swapup.onPress = function(){if(swap < 2){swap++;}}
    swapdown.onPress = function(){if(swap > 0){swap--;}}
    fruitlist.text = afruit[swap];
    erase.onPress = function(){
    if(fruitlist.text == String(" orange")){afruit.splice(1,1);
    seeker = afruit.getIndex("apple"); outpuut.text = afruit.splice(seeker,1);
    but I don't have a clue why essentially the same program doesn't work for my larger arrays. I also feel this version is rather cumbersome and would prefer my function contain the splice (but don't know how). In the large program I have this prerequisite system rigged so if you add certain elements to a list, prerequisite elements are added as well, using the format:
    addmcI.onPress = function(){
    if(mylistedelement == "ElementwithPrerequisite"){myArray.push(" "+ "Prerequisite");}
    I'm seriously wondering if the reason my fruit list works and my main program doesn't is because of the " "+ added.

Maybe you are looking for

  • I can't open batch files in windows 8.1

    I am trying to run a batch file in windows 8.1, when i run the batch file runs at first but closes so fast that you can't see its contents, you can't even see if its doing what you tell it to. Since the file does run but closes fast, i thought of add

  • Snow Leopard 10.6.1 Clone not appearing in Startup Disk

    Before attempting to upgrade to 10.6.2, I made a bootable clone using Disk Utility of 10.6.1. I followed the same procedure I used successfully to create a bootable clone of 10.4.11 just a few days ago on a separate partition of my external drive. Af

  • Maximum Number of Pages and File Size for PDFs

    Assuming that your computer has ample CPU, memory,and storage, how many pages and what file size does Adobe recommend that you limit a single PDF to using Acrobat Pro XI in order to avoid any issues.

  • Camera profile with CS2 and DNG

    If I embed a camera profile in a DNG file and open it in ACR for Photoshop CS2, will I have the benefit of the camera profile?

  • Booting from a Novell Linux CD

    Why can't I boot my new iMac (intel core2 duo) from a Novell Linux based CD (Zenworks) that would allow me to image my other iMacs?