Classy, yet complicated

24 02 2010

Well, I got Flash and Processing talking from within AS files (make a separate Actionscript Class file with all the code in it, and name it the name of your class; your main Flash file will have no “actions” but instead be of the same document type as the AS file; it’s much neater).  It took a while (I ran into tons of errors and eventually winnowed my code down to one file to avoid static type errors), and I still need to get the masking property to work, but all in all I’m pleased with myself for figuring out all of the errors!





ActionScript 3.0 XMLSockets are a pain…

17 02 2010

You can find my code from today here, and yesterday’s here.  Compared to the ease of making Processing talk to Flash in AS2.0, AS3.0 is a nasty, hairy spider with knives for legs sitting on my laptop.  Laughing at me.  Seriously, I keep getting error after error, the most recent (and most confusing) one is:

Connection successful
ReferenceError: Error #1069: Property split not found on flash.events.DataEvent and there is no default value.
at FlashSocketAS3_fla::MainTimeline/dataHandler()

Why can’t it find the split() function?! (The split function allows me to take my string of “1,1,7.83457,1,2,8.34985,1,3,7.68472″ et cetera and easily separate it into the sensible pieces from which it’s made, namely: {integer, integer, long float decimal value} repeated 850 times for each point on my Processing video feed.)  And I don’t know what’s up with the “no default value.”  Grr.  I really, REALLY don’t want to have to draw my circles in AS2, but if I can’t figure this out, I may have to.

WHY?!  I will go get my peanut butter and other essential groceries and look at this again upon my return. X(

UPDATE: Several hours and crashes later (luckily I save before running anything)… I’ve given up on AS3.o for the moment, and am attempting to draw circles in AS2.o via a method that is pretty clean.  So far, I have a curious set of densely compacted concentric circles that meander back and forth across the stage in no pattern I can discern, but correctly in time with the socket data Processing is sending (every second, via the delay function).  I think I need to figure out how to determine the stage size (I’m using the createEmptyMovieClip(String name, int level) method.  The function below is the one I’m working on at present, trying to use the data from the socket (correctly sorted into rArray, xArray, and yArray, each an array of radii, x-coordinates, and y-coordinates) to draw the corresponding circles that my Processing sketch gives me.  See Processing Circles and Flash Circles.

function drawMask() {

this.createEmptyMovieClip(“clip”,0);

with(_root.clip) {

.beginFill(0×000000);

for(i=0; i<rArray.length; i++) {

drawCircle(rArray[i], xArray[i], yArray[i]); //radius, x, y

trace(“circle drawing works!”);

}

endFill();

}

}








Follow

Get every new post delivered to your Inbox.