From ActionScript to Processing: In Quest for the Push-Method
Sat, 01 Aug 2009
Dabbling into processing (coming from ActionScript 3) one of the first things I was looking for was an equivalent of Array.push() and its relatives to store and manage a growing amount of objects during runtime. Astonished I realized that there is no such thing.
After some searching the java Vector-class presented itsalf as a possible surrogat for an AS-like array. Processing being a kind of a “wrapper” for java you can use java classes inside it, like this:
import java.util.Vector;Vector a = new Vector();void setup () {}void draw (){ a.add(new Dot( random(200), random(200)));}class Dot { float x,y; public Dot ( float x_param, float y_param ){ x = x_param; y = y_param; }}The vector is not exactly the same as an array in AS (or Perl), but it’s close – see this for details.