Cope with non-Loader media objects that have set up their own masks.
God, what a disaster. I'd say the right thing to do would be to add the mask directly to the media container, but we rely in a few places on being able to easily decorate the media container by winging other objects off the edges, and we don't want to just create one mask that's big enough for the user media as well as our decorations (because then malicious user media could alter what the user perceives as our decorations). Perhaps the right thing to do is make MsoySprite not be a subclass of MediaContainer, but contain one. That's a refactor I won't be rabbit-holing right now, thankyou. git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@176 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
@@ -220,10 +220,19 @@ public class MediaContainer extends Sprite
|
||||
public function shutdown (completely :Boolean = true) :void
|
||||
{
|
||||
try {
|
||||
// remove the mask
|
||||
// remove the mask (but only if we added it)
|
||||
if (_media != null && _media.mask != null) {
|
||||
removeChild(_media.mask);
|
||||
_media.mask = null;
|
||||
try {
|
||||
removeChild(_media.mask);
|
||||
_media.mask = null;
|
||||
|
||||
} catch (argErr :ArgumentError) {
|
||||
// If we catch this error, it was thrown in removeChild
|
||||
// and means that we did not add the media's mask,
|
||||
// and so shouldn't remove it either. The action we
|
||||
// take here is NOT setting _media.mask = null.
|
||||
// Then, we continue happily...
|
||||
}
|
||||
}
|
||||
|
||||
if (_media is Loader) {
|
||||
@@ -436,6 +445,19 @@ public class MediaContainer extends Sprite
|
||||
{
|
||||
var mask :Shape;
|
||||
if (_media.mask != null) {
|
||||
// see if the mask was added by us
|
||||
try {
|
||||
getChildIndex(_media.mask);
|
||||
|
||||
} catch (argErr :ArgumentError) {
|
||||
// oy! We are not the controllers of this mask, it must
|
||||
// have been added by someone else. This probably means
|
||||
// that the _media is not a Loader, and so we should just
|
||||
// leave it alone with its custom mask.
|
||||
return;
|
||||
}
|
||||
|
||||
// otherwise, it's a mask we previously configured
|
||||
mask = (_media.mask as Shape);
|
||||
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user