# Flex 2: Crash Bug in Canvas.measure

**URL:** <https://forum.kirupa.com/t/flex-2-crash-bug-in-canvas-measure/203040>\
**Category:** flash\
**Created:** [October 6, 2006, 7:47pm UTC](https://forum.kirupa.com/t/flex-2-crash-bug-in-canvas-measure/203040 "2006-10-06T19:47:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dougsha](https://avatars.discourse-cdn.com/v4/letter/d/22d042/32.png) [@dougsha](https://forum.kirupa.com/u/dougsha)\
**Post date:** [October 6, 2006, 7:47pm UTC](https://forum.kirupa.com/t/flex-2-crash-bug-in-canvas-measure/203040/1 "2006-10-06T19:47:24Z")

</div>

Here is a bug that’s been biting me for a couple weeks. Here’s a screenshot of Flex when it errors.

[[COLOR=#810081]Screenshot of maddening error[/COLOR]](http://zogax.com/error2.gif)

The program croaks when measureContentArea (in package mx.containers.utilityClasses, file CanvasLayout.as ) loops through the target’s children from 0 to target.numChildren. When the program errors: n == 1, i == 0, and target.numChildren is now 0, when it was 1 before the loop. target.numChildren has changed while the loop is running. It’s as if a child was removed by some side effect of calls in the loop.

This happens even when I have many IOComponents on the screen: [[COLOR=#810081]Here[/COLOR]](http://zogax.com/getChildAt_RangeError.gif)

This baffles me because I don’t see how I can debug it. I do add and remove and insert children in my game code, but unless ActionScript is threaded I don’t see how my code can reach into a loop in CanvasLayout.as .

The bug is consistent, but I am baffled.

HELP!
