Tuesday, September 10, 2013

i have to work with tools like the one mentioned in the title. here is a bug that only happens if you assign code to a frame in the (main) timeline. target version is 12.0.0.481 and could be fixed in later interations.you can try the following:// Array can be used here instead, for 'list'var list:Vector.<String> = Vector.<String>(["hello", "world"]);trace(list); // hello,worldvar vlen:uint = list.length;trace(vlen); // 2const clen:uint = vlen; // this works but 'vlen' is zero at this pointtrace(clen); // 0const len:uint = list.length; // list is a null object referenceresults in:TypeError: Error #1009: Cannot access a property or method of a null object reference.at Untitled_fla::MainTimeline()
what happens here is that the as3 compiler tries to play smart and traverses for 'const' declarations, and once it finds 'len' it decided to assign a value to the address where it will be stored in the 'constant pool' and then to be referenced by bytecode. but since 'list' is not a 'const' declaration itself the object is simply not constructed yet and 'list' is a null reference.
same does not happen if:- 'const list:...' is used, but one may not want that- if the same code is written in an external document class instead on the timeline
if this is by design it may cause compatibility issues with class written code and simply confuse developers. after all, constant declarations after variable declarations should make perfect sense. in general, i wouldn't recommend writing anything more important on timeline frames, but use classes with ENTER_FRAME listeners or attempt to use addFrameScript() on MovieClip instances instead.
--