A while ago I posted about casting failing if you cast the result of attachMovie() but only in certain cases.
I had the same thing happen today, so I opened it up in FLASM, and I think I can see what is happening:
push 'sp' getVariable trace push 'sb', 0.0, 'getNextHighestDepth' callFunction push 'sb', 'com' getVariable push 'domain' getMember push 'controls' getMember push 'ScrollBar' getMember push 'LINKAGE' getMember push 3, 'attachMovie' callFunction push 1, 'com' getVariable push 'domain' getMember push 'controls' getMember push 'ScrollBar' callMethod varEquals As you can see here, it seems instead of performing a cast operation (and “cast” is a keyword you do see in the FLASM output), it actually tries to perform a conversion (as you see with Array or Boolean), treating com.domain.controls.ScrollPane as a function, and applying it to the result from the attachMovie() operation. This results in the undefined/null value we are experiencing because in itself, this function has no return value unless used with the new keyword as a constructor.
...