Posts Tagged ‘as3’

Error optimizing byte code


Actually it will, but that is beside the point...

Or, why I would sometimes like to kill and maim in the world of virtual machines. Why can’t we just all program C++. Y U NO MEMORY LEFT?!!11

When you are like me, you are writing vast, bloated pieces of Flash because you keep thinking up ridiculous requirements for your games. Let’s take our new ANWB/TNO game for example (we’re still in the market for new names, apart from “CARamba!”)

Now the first problem is connecting over a thousand road pieces. Most of it by hand, since it is all quite intricate stuff. But when I reached about half the map, my script that tries to find out what directions the car should take exploded. Stack Overflow. Kablooie.

So I could build the map up unto 15 seconds of script execution time. Which was about half the map. Now Gnuif is brilliant but still took almost a week to rewrite the code in such a way that we were able to bring execution times back to under a second. Nice going.

Then I finally fixed the Map but flash exploded in my face with it’s mysterious 5005: end of bytecode.

So I was like WT-fucking-F?!

It appears that the Java virtual machine, Java being the language in which flash is written, has a memory buffer limit of 128MB. Also for compiling. Which basically means that if you try to compile BIG flash files it blows up in your face.

Of course there is a trick. There always is. They Write about it over here and Google is actually quite helpful

[...] To do that in Windows: right click on my computer -> properties -> advanced -> environment variables -> make a new variable:


and add this value:


Then log out or restart.

There was an issue when I opened Flash CS4 after the restart. I got the message:
“Error initializing Java Runtime Environment. You may need to reinstall Flash.”
I had to change the value from -Xmx1024M to -Xmx256M (or -Xmx128M). A value of -Xmx512M and higher causes every time the error “Error initializing JRE. You may need to reinstall Flash”.

After I set up the variable “JAVA_TOOL_OPTIONS” with value “-Xmx256M” everything started working fine.

Sigh. Ow Adobe, why are you making my life so much harder ?

Posted: April 5th, 2011
Categories: nerd, research, web, work
Tags: , , , , , ,
Comments: No Comments.

Breaking Flash references through serialization

Here is to Google: this article needs to be found by As3 Flash and Flex programmers on the keywords: serialization, JSON, encoding, decoding,  referencing, object referencing, breaking referencing and complicated objects, Resistance is futile. Programming, actionscript. Flash hack, and the final way to un-reference objects in flash.

So here is the git of it; when you want to break references in as3 for a copy or a clone you usually need to get the stuff out of an object and put it back in again; this is hard with complicated objects, but luckily this exactly the same as serialization! for instance through JSON, which is already available in the neatly packed library Casalib

So your copy can be written as:

var copyObject = JSON.decode(JSON.encode( originalObject ))

Well now. I intended to write this in such a way that everybody would be able to understand this, but after a few days of pondering, I’ve decided that that would never work. So I’ll try to keep it brief and interesting, but if you have no idea what as3 is, or referencing for that matter; I’m not sure you’ll get this. Still what I’m writing here is about sheer brilliance and beautiful insight AND I have a picture of the Alien Love Messiah:


Posted: February 6th, 2011
Categories: general, media, nerd, research, technology, web, work
Tags: , , , , , , , , , ,
Comments: No Comments.

AS3 Bug of the Week (again? Yes, again)

URLDecoding is one of those things that makes life a little bit more of a pain.

the idea is that in a typical URL certain characters are not allowed; for instance an % or an $ or & are used for functions in URLs, and can thus not be used. Now that is a pain, since some URLs need them. For instance needs to be escaped as the space and the ampersand cannot be used directly. This is done with a %26 sign; ( Every decent programming language has a function called escape or URIdecode to do this for you.

Flash has it too, you can find it in the manual however, it escaped %23, %24 and %26 the %25 escape (the %-sign) is strangely missing and will throw an error.


Because the people at Adobe want to kill me. Or so I think. Why?! Why can’t I escape %-signs?!

The workaround is simple, and reads something like:

function escapeURL(someURL:String):String {
 someURL = someURL.split("%").join("P")
 someURL = URLDecode(someURL)
 return someURL

In the split I replace the % signs with P’s, cuz’ if i was to replace them with %25 it still crashes.

Why, Adobe?! WHY…

Posted: June 15th, 2010
Categories: nerd, technology, web, work
Tags: , , , , , , , ,
Comments: No Comments.

I can haz Audiomixer?



So we are tinkering with this interactive video platform, Marduq, and I wanted to make an Mp3 player, to go with your video. Or slideshow. Or whatever. Like so. But you may notice that if you start fiddling with the volume, the system breaks. Crashes. Burns. Death. Agony.Wailing.

This is because in Marduq, we only have 1 channel of audio mixing, ie. the video-soundtrack. But as research of Surfinnetje showed over a year ago: Watching snowboarders in a half-pipe and choosing different mp3-files is fun. So we needed a way to track different soundtracks in the system. Both mp3, system sounds, ambient sounds, youtube sounds and video sounds. And of course a master.

Well. Here is the prototype.

* applaus *

* applaus *

This thing mixes a youtube channel and flash net video together with a couple of mp3 files. The mp3 even have balance dials The youtube and the master have balance dials, but they do nothing. Also. The video and youtube can not be paused in this prototype. The PlayheadController will take care of that.

And when you start-up, everything is ON . TOGETHER. Making NOISE!

And some props. On a side note. I can now also build twoyoutubevideosandafuckingcrossfader. Now if only I could get those youtube players to pitch… hmm…

Posted: April 29th, 2010
Categories: nerd, research, site, technology, web, work
Tags: , , , , , , , , ,
Comments: No Comments.

PsysiXX are cool


“It’s so… Alive ?”

Soo… I was tinkering with a project for a company called 9292. The problem was this; I needed to draw buttons (or dots actually) on a map of the Netherlands, only the coordinates are set per city, an not on the actual location. This can result in multiple dots in one place.
Now here is a problem because users need to be able to click on the different dots, which they can’t if dots overlap each other. Agony. Headache. Problem.

So this got me thinking; First, I thought, making some random variations to the x and y coordinates would solve it. Alas; even with random variations dots can still intersect and Overlap.
Then Gnuif pointed me to a system where every second dot in the same place is mapped in a spiral, thus never making them intersect. But although it seemed to work, I didn’t find it satisfactory. All those spirals gave weird and unnatural patterns on my map.

So I tried a different route, adding the dots to a Particle System where I gave all the dots a negative gravitation. With an inverted mass, the dots would repel one and other.
Now if a number of dots happen to be in the same place, they will repel each other until their boundaries stop touching.  Tada! Problem solved.


Posted: April 20th, 2010
Categories: web, work
Tags: , , , , ,
Comments: 1 Comment.

Flash AS3 Bug of the Week

SecurityError: Error #2121:  Security sandbox violation: SoundMixer.computeSpectrum:  
cannot access
This may be worked  around by calling Security.allowDomain.
at  app::Spectrum/onLoop()

So. I was tinkering with a ComputeSpectrum function in, Flash for Marduq, which basically gives you a music equalizer display. Little bars going up and down with music.. Nifty. So I build it in and started to get really weird security bugs. First I thought it my allowDomain(*) then my crossDomain.xml policy files. Then I asked Urias. Then Daniel. Then I started to scream and bitch and moan. Then I started drinking beer. Then, finally, I found this bug report: [#FP-147] which basically told me to write the fucking spectrum analyzer myself.

It’s these kind of bugs that makes me want to switch platform.


Posted: April 13th, 2010
Categories: nerd, research, site, technology, work
Tags: , , , , , , , , , , , ,
Comments: No Comments.

Zoning out

Zoning out. Just zoning out. Turn on, tune in and drop out.

We’re finishing up the most complicated project untill now. To be honest it isn’t the most pretty code I’ve ever written but it’s neat.  If you like to check it out: NL tracks. It’s dutch only I’m afraid.

This one has really a potential to grow. Tonight we had a group session with some people from the target-audience, working with the site. It is really nice to see people working with a product that we made. It reminds me of Apenkooi; when the first guy actually completed the game in 17 seconds. Later he came up to me while I was veejaying and told us he was the guy. I told him to take the stage and play the game for us on the screens in the club and he amazed us by completing the course in 18 seconds. My personal record still is at 21 seconds Wink

In any case, after almost a year of research and programming we have come up with a beta that -I think- has great potential.Technical details include a completely XML-skinned application on a ‘canvas’ interface. It’s is like google maps, it can be dragged around. All interactive elements can talk to each other and the system tries to show relations with the ‘current’ content (a radio, a video, news) and the ‘other content’. We’re now applying it to light-news and music, but be fitted easily for an important news event (elections 2008? georgia crisis). The content is mostly ‘generated’ from other sources and used in the site.

I don’t say it a lot, but I’m kind of proud

Now it’s time to take a step back. To zone out a bit. focus on friends, family and more. This is XangadiX, zoning out.

Posted: September 23rd, 2008
Categories: vj, web, work
Tags: , , , , , , , , ,
Comments: No Comments.

Why Joost fails

“Sex sells”

- fact

Actually the rule-of-porn, as we like to call it, isn’t as widely applicable as most media-theorist would have us believe. Yes it did win the VCR-wars of the eighties, and it has been a factor in the CDROM wars of the early nineties, but it hasn’t been a factor for youtube and the Porn industry actually opposes the HD revolution. Having said that, I still think that if Joost wants to get any market share, they should start serving porn now.

Who still remembers Joost ? The heavily anticipated television-on-demand program that uses peer-to-peer technology. It should have been the killer-app for the new age. It would bring the personal computer to the living room at last and it would revolutionize the way we perceived television. 18 months later the service is sill in Beta, waiting times are annoyingly long and the content is mediocre at best.

So what this program need is PORN. lots and lots of porn. A payment gateway to watch porn and an amazing collection of naked young women getting drilled by big black guys. No really. And I can prove it too; the flash-clone of Joost by Paul Yanez, is used more then Joost itself. The program simply plugs into Youtube, or any video site for that matter, including pornotube!

I rest my case. Read more about it,  It seems that the laws of old, sometimes still serve the new. Goodnight, Joost.

Posted: April 22nd, 2008
Categories: media, web, work
Tags: , , , , ,
Comments: No Comments.

I hate Flash (AS3 part 3)

We are the Borg. You will be assimilated. Resistance is futile. Your distinctiveness will be added to our own…

- Star Trek

We had a glitch in the CNR website; on a Macintosh (may God punish the users of Apple with lightning and fire) the small Flash application that scrolls the pictures was making errors. When loading the page and clicking outside the browser window would make the pictures go berserk. Now I blamed my intern for writing sloppy code and thought nothing of it. In the v2 of the side I rewrote the entire thing in AS3, thinking that would fix the problem. The original file had used a tween-animation and a masking movieclip to make the animation and the ‘reflection’, in the new AS3 application everything was done in code.

So imagine my surprise when I found out that the new version exhibit the exact same error as the original one. I searched the web for hours but couldn’t find this bug anywhere. I found that quite odd because it seemed so elementary to me. Until there where some vague references to it on Flashkit forums. Still I haven’t found any to fix it to my satisfaction; but it seems that on an Apple running OSX mouseclicks are still recorded, even when the browser window, let alone the Flash application, loses focus. So if I click left from the window flash will still receive a (negative) mouse coordinate. Sloppy work there at Apple. frustrating too. I am now making plans to get some niggers from the hood and get medieval on Steve Jobs ass. (apple bashing is now off)

update: Waxle and I have been tinkering with this last nigth, and it is as I expected, OSX gives back weird coordinates when clicking outside the browser window. But it doesn’t return a number relative to the 0, 0 coordinate in Flash, but a rather weird but static number. Consider the following script:

addEventListener(Event.ENTER_FRAME, update)
addEventListener(MouseEvent.CLICK, clickHandler)
var mX:Number
var mY:Number

function update(evtObj:Event) {
mX = mouseX
mY = mouseY
msg.text = mX + “, ” + mY

function clickHandler(evtObj:Event) {
msg2.text = “the mouse was clicked at: ” + mX +”, ” +mY

Paste it in frame one and create 2 textfields (msg and msg2). You will now trace the mouse coordinates on ENTER_FRAME and register clicks. This works fine within flash but on macintosh it returns the following when clicking outside the browser:


Click for larger image

107374143.5 -107374182.4 ?!! (which does google some results, but still). The workaround is of course to limit the mouseX input by something like if (mouseX > 0 and mouseX < stage.stageWidth) but still.

What can produce such an error? different assignment of the register in Moterola chips? The overlays with the ’sensitive corners’ in Mac OSX ? I really don’t know.

But still, here is the problem and a workaround, thanks to Waxle who tested this through on the mac. And with this file: mousetracer2.swf you can test it for yourself.

Posted: April 3rd, 2008
Categories: nerd, research, technology, work
Tags: , , , , ,
Comments: No Comments.

the beauty of AS3 (part 2)

We are the Borg. You will be assimilated. Resistance is futile. Your distinctiveness will be added to our own…

- Star Trek

Ow god, ow god why didn’t I jump on this train earlier? Actionscript 3 rules, not even because it has such a simple and powerful structure. Not because exchange of classes and knowledge has become so simple. Not because it’s so damned fast and supports full control of your sockets and HD video material; but simply because you can write a spectrum analyzer in under 10 lines of code. You don’t want to know how many faul tricks and hacks I’ve used to build a simple analyzer. And now, it’s just there. So simple. So elegant…

//spectrum analyzer codes

var byteArray:ByteArray = new ByteArray();

var byteArray2:ByteArray = new ByteArray();

function maakSpectrum(event:Event) {

SoundMixer.computeSpectrum(byteArray, true, 2); // FFD

SoundMixer.computeSpectrum(byteArray2, false, 1); // WAVE

graphics.clear(); //meterjes weghalen

for (var i:Number = 0; i < 512; i += 4) {//aantal “metertjes”

if (i<256) {

graphics.lineStyle(0, 0xff3333);



graphics.lineStyle(0, 0×33ff33);



graphics.drawRect(i + 20 , 100, 2, byteArray2.readFloat() * 100);

if (i%16 == 0) {

frame = Math.round(    byteArray.readFloat() * 100 )





Such beauty (sigh)

Posted: March 24th, 2008
Categories: nerd, web, work
Tags: , , ,
Comments: No Comments.

It had to happen…

We are the Borg. You will be assimilated. Resistance is futile. Your distinctiveness will be added to our own…

- Star Trek

Ow god, I’m joining the hyve mind. I can’t help it. It feels like learning to snowboard for the first time, after years of skiing. Yes, I finally have the time to learn OOP and actionscript 3.0. I’m just past the steep learning curve and start to mutter my first complete sentences, but truth be told, I’m now just able to throw a few bouncing balls around. But I’m getting the hang of it.

I can now throw important sounding words like inheritence and polymorphism around the office and get an approving nod from other programmers. I like that. The ideas behind it are, as always, quite simpel and sharing code almost becomes mandatory with OOP systems. Still, I have to see it in use to really rant about it. Still, it seems a very interesting and useful tool, maybe that is why the whole programmers community is using it.

And I finally found out what the difference betweek & and && is. Cool

Posted: March 3rd, 2008
Categories: nerd, work
Tags: ,
Comments: No Comments.