SWF issue with V9 and scale9Grid (9-slice)

We are in process of converting from 8.9.7 to 9.0.2 (using SWF 3.0.2 in either case.) When executing this line in the 9.0.2 version:

avamc = Assets.getMovieClip("AvatarDisplay_art.swf:ava");

there’s an exception. The first few lines of the call stack are:

Uncaught TypeError: shape.get_graphics is not a function
at swf_exporters_animate_AnimateTimeline.enterFrame (AnimateTimeline.hx:366:36)
at swf_exporters_animate_AnimateTimeline.attachMovieClip (AnimateTimeline.hx:248:3)
at swf_exporters_animate_AnimateTimeline.__attachMovieClip (Timeline.hx:103:3)

The AnimateTimeline code is crashing in the copyFrom() routine below.

// TODO: How to tell if shapes are for a scale9Grid clip?
if (__movieClip.scale9Grid != null)
{
    __movieClip.graphics.clear();
    if (currentInstances.length > 0)
    {
        var shape:Shape = cast currentInstances[0].displayObject;
        __movieClip.graphics.copyFrom(shape.graphics);
    }
}

The reason it’s crashing is that it’s casting a Text item and not a Shape item. The MovieClip it’s working on has a 9-slice defined and contains just two children, a text and a shape. If I edit the library to trap that and use currentInstances[1] instead, it works. The code preceding this has done a sort on currentInstances, but it’s not clear to me why it’s believed that will guarantee the 0-th element will then be a shape.

In any case, we worked around this by making a new SWF where the two cases like this are not 9-slice anymore, and we’re up and running again. I didn’t see anything related in the fora. I don’t know whether this is an OFL bug, or some subtle violation we’ve done, but it seems worth mentioning this issue.

This may not the correct solution in the end, but it may be a temporary improvement to check the type of the first item in currentInstances to be sure it’s what we expect it to be.

var shape:Shape = Std.downcast(currentInstances[0].displayObject, Shape);
if (shape != null)
{
    __movieClip.graphics.copyFrom(shape.graphics);
}
1 Like