If the key you gave me was correct. Then it should have worked. I have gone over your code compared it to the decompiled version function by function of the stream4k.to encode.swf and the code is exact. I also under stand why you have those two extra lines. First one is to create the array set elements value to 0 and the second is to check the size of the key length.