Added isContentInitialized(), which should be used to help differentiate

between an MsoySprite that does not have any WhirledControl subclass in it
and those that do, but are just not yet fully loaded.


git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@219 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
Ray Greenwell
2007-05-02 00:10:00 +00:00
parent 072926f814
commit 330a99f337
+24 -1
View File
@@ -94,6 +94,16 @@ public class MediaContainer extends Sprite
mouseChildren = true;
}
/**
* Return true if the content has been initialized.
* For most content, this is true if the media is non-null, but
* for anything loaded with a Loader, it is only true after the INIT event is dispatched.
*/
public function isContentInitialized () :Boolean
{
return (_media != null) && (_initialized || !(_media is Loader));
}
/**
* Get the media. If the media was loaded using a URL, this will
* likely be the Loader object holding the real media.
@@ -158,7 +168,7 @@ public class MediaContainer extends Sprite
*/
protected function willShowNewMedia () :void
{
// nada in here
_initialized = false;
}
/**
@@ -186,6 +196,7 @@ public class MediaContainer extends Sprite
_media = loader;
var info :LoaderInfo = loader.contentLoaderInfo;
info.addEventListener(Event.COMPLETE, loadingComplete);
info.addEventListener(Event.INIT, handleInit);
info.addEventListener(IOErrorEvent.IO_ERROR, loadError);
info.addEventListener(ProgressEvent.PROGRESS, loadProgress);
@@ -398,6 +409,7 @@ public class MediaContainer extends Sprite
protected function removeListeners (info :LoaderInfo) :void
{
info.removeEventListener(Event.COMPLETE, loadingComplete);
info.removeEventListener(Event.INIT, handleInit);
info.removeEventListener(IOErrorEvent.IO_ERROR, loadError);
info.removeEventListener(ProgressEvent.PROGRESS, loadProgress);
}
@@ -445,6 +457,14 @@ public class MediaContainer extends Sprite
setupBrokenImage(-1, -1);
}
/**
* Handles the INIT event for content loaded with a Loader.
*/
protected function handleInit (event :Event) :void
{
_initialized = true;
}
/**
* Callback function to receive COMPLETE events for swfs or images.
*/
@@ -560,5 +580,8 @@ public class MediaContainer extends Sprite
/** Either a Loader or a VideoDisplay. */
protected var _media :DisplayObject;
/** If we're using a Loader, true once the INIT property has been dispatched. */
protected var _initialized :Boolean;
}
}