Help with setMask

Essentially, I am trying to fill a graphic with a pattern, which is loaded externally via XML.

This is my code (it doesn’t work):

[AS] selectedGraphic = _root[“container” + (selection-1)];

patternToBeMasked = _root.createEmptyMovieClip("pattern" + (selection-1), getNextAvailableLevel());
patternToBeMasked.loadMovie(fileName);

patternToBeMasked.setMask(selectedGraphic);[/AS]

The graphics are loading properly, but the setMask command seems to have no effect. Is there something else I should be doing? Is setMask sensitive to levels or how movieclips are nested within each other?