[haXe] bug? __keys__ causes Error #1068 when used in a nested block

Baffo32 baffo32 at gmail.com
Sat Apr 7 18:14:11 CEST 2007


Maybe this is just me over-using 'magic' features again, but if I compile
and play this flash 9 code:

class KeyTest
{
  public static function main() {
    if(true) {
      untyped __keys__(new flash.utils.Dictionary());
    }
  }
}


then I get the runtime exception (in debug player) "VerifyError: Error
#1068: Array and * cannot be reconciled" which the flash api docs state is
caused by a corrupted swf.  When this exception was repeated over and over
every frame in my original application, despite me catching and handling the
exceptions properly, flashplayer segfaulted after only a few seconds!

Removing the if(true) { } block surrounding the code resolves the problem.
Replacing it with a try { } catch() { } block causes a similar error.

I've been experimenting with using __keys__ because Hash.keys () has been
causing my memory usage to steadily increase for each call; however __keys__
also seems to have this memory leak.  Looking at how __keys__ seems to be
implemented, it populates an entire new array object each call.  All I want
to do is loop over every key and perform a task on it; some kind of
__keysloopcallback__ function that takes an object and a callback to call on
each property of that object would be very nice, e.g:

var dict:flash.utils.Dictionary;
var callback = function(key:String) { dosomestuff(key); }
untyped __keysloopcallback__(dict, callback);

I looked into implementing this myself, but I found __keys__ is implemented
with raw AS3 bytecodes, which combined with my total lack of understanding
of ocaml rather threw me off (are there any introductory or reference
informations on using swflib out there?).  I can't either find any way to
include raw as3 code or as3 bytecodes (support for this would be awesome!)
into my haXe source.  I'll probably see if I can implement this
__keysloopcallback__ function in as3, compile with flex2, and link the swf
in.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.motion-twin.com/pipermail/haxe/attachments/20070407/0fc2104b/attachment.htm


More information about the Haxe mailing list