Packagecom.threerings.media
Classpublic class MediaContainer
InheritanceMediaContainer Inheritance flash.display.Sprite
SubclassesScalingMediaContainer

A wrapper class for all media that will be placed on the screen. Subject to change.



Protected Properties
 PropertyDefined by
  _h : int
The unscaled height of our content.
MediaContainer
  _initialized : Boolean
If we're using a Loader, true once the INIT event has been dispatched.
MediaContainer
  _isImage : Boolean
Are we displaying an image?
MediaContainer
  _media : DisplayObject
Either a Loader or a VideoDisplay.
MediaContainer
  _url : String
The unaltered URL of the content we're displaying.
MediaContainer
  _w : int
The unscaled width of our content.
MediaContainer
Public Methods
 MethodDefined by
  
MediaContainer(url:String = null)
Constructor.
MediaContainer
  
containerDimensionsUpdated(newWidth:Number, newHeight:Number):void
Called by MediaWrapper as notification that its size has changed.
MediaContainer
  
Get the height of the content, bounded by the maximum.
MediaContainer
  
Get the width of the content, bounded by the maximum.
MediaContainer
  
Get the maximum allowable height for our content.
MediaContainer
  
Get the maximum allowable width for our content.
MediaContainer
  
getMedia():DisplayObject
Get the media.
MediaContainer
  
getMediaScaleX():Number
Get the X scaling factor to use on the actual media.
MediaContainer
  
getMediaScaleY():Number
Get the Y scaling factor to use on the actual media.
MediaContainer
  
hitTestPoint(x:Number, y:Number, shapeFlag:Boolean = false):Boolean
Note: This method is NOT used in normal mouseOver calculations.
MediaContainer
  
Return true if the content has been initialized.
MediaContainer
  
setMedia(url:String):void
Configure the media to display.
MediaContainer
  
setMediaBytes(bytes:ByteArray):void
Set the media to display as a ByteArray.
MediaContainer
  
setMediaClass(clazz:Class):void
Configure our media as an instance of the specified class.
MediaContainer
  
setMediaObject(disp:DisplayObject):void
Configure an already-instantiated DisplayObject as our media.
MediaContainer
  
setShutdownOnRemove(enable:Boolean = true):void
Sets whether this MediaContainer automatically shuts down when removed from the stage.
MediaContainer
  
shutdown(completely:Boolean = true):void
Unload the media we're displaying, clean up any resources.
MediaContainer
  
toString():String
MediaContainer
Protected Methods
 MethodDefined by
  
addListeners(info:LoaderInfo):void
Add our listeners to the LoaderInfo object.
MediaContainer
  
configureMask(rect:Rectangle):void
Configure the mask for this object.
MediaContainer
  
Called when we know the true size of the content.
MediaContainer
  
createVideoUI(player:VideoPlayer):DisplayObject
Create the actual display for the VideoPlayer.
MediaContainer
  
A place where subclasses can configure things after we've setup new media.
MediaContainer
  
getContext(url:String):LoaderContext
Return the LoaderContext that should be used to load the media at the specified url.
MediaContainer
  
getMaskRectangle():Rectangle
Get the mask area, or null if no mask is needed.
MediaContainer
  
getSecurityDomain(imageURL:String):SecurityDomain
Return the security domain to use for the specified image url.
MediaContainer
  
handleComplete(event:Event):void
Callback function to receive COMPLETE events for swfs or images.
MediaContainer
  
handleError(event:ErrorEvent):void
A callback to receive IO_ERROR and SECURITY_ERROR events.
MediaContainer
  
handleInit(event:Event):void
Handles the INIT event for content loaded with a Loader.
MediaContainer
  
handleProgress(event:ProgressEvent):void
A callback to receive PROGRESS events.
MediaContainer
  
handleShutdownOnRemove(event:Event):void
Handle shutting us down when we're removed.
MediaContainer
  
initLoader():Loader
Initialize a Loader as our _media, and configure it however needed to prepare loading user content.
MediaContainer
  
isImage(url:String):Boolean
Does the specified url represent an image?
MediaContainer
  
removeListeners(info:LoaderInfo):void
Remove our listeners from the LoaderInfo object.
MediaContainer
  
setupBrokenImage(w:int = -1, h:int = -1):void
Display a 'broken image' to indicate there were troubles with loading the media.
MediaContainer
  
setupSwfOrImage(url:String):void
Configure this sprite to show an image or flash movie.
MediaContainer
  
setupVideo(url:String):void
Configure this sprite to show a video.
MediaContainer
  
showNewMedia(url:String):void
MediaContainer
  
Do whatever is necessary to shut down the media.
MediaContainer
  
Called when we've started loading new media.
MediaContainer
  
Called when we've stopped loading, which may be as a result of completion, an error while loading, or early termination.
MediaContainer
  
updateContentDimensions(ww:int, hh:int):void
Called during loading as we figure out how big the content we're loading is.
MediaContainer
  
updateLoadingProgress(soFar:Number, total:Number):void
Update the graphics to indicate how much is loaded.
MediaContainer
  
A place where subclasses can initialize things prior to showing new media.
MediaContainer
Events
 EventSummaryDefined by
   Dispatched when we've shown new media.MediaContainer
   Dispatched when we've initialized our content.MediaContainer
   Dispatched when the size of the media being loaded is known.MediaContainer
   Dispatched when we've unloaded our content...MediaContainer
Public Constants
 ConstantDefined by
  SIZE_KNOWN : String = "mediaSizeKnown"
[static] A ValueEvent we dispatch when our size is known.
MediaContainer
Protected Constants
 ConstantDefined by
  log : Log
[static] A log instance that can be shared by sprites.
MediaContainer
Property detail
_hproperty
protected var _h:int

The unscaled height of our content.

_initializedproperty 
protected var _initialized:Boolean

If we're using a Loader, true once the INIT event has been dispatched.

_isImageproperty 
protected var _isImage:Boolean

Are we displaying an image?

_mediaproperty 
protected var _media:DisplayObject

Either a Loader or a VideoDisplay.

_urlproperty 
protected var _url:String

The unaltered URL of the content we're displaying.

_wproperty 
protected var _w:int

The unscaled width of our content.

Constructor detail
MediaContainer()constructor
public function MediaContainer(url:String = null)

Constructor.

Parameters
url:String (default = null)
Method detail
addListeners()method
protected function addListeners(info:LoaderInfo):void

Add our listeners to the LoaderInfo object.

Parameters
info:LoaderInfo
configureMask()method 
protected function configureMask(rect:Rectangle):void

Configure the mask for this object.

Parameters
rect:Rectangle
containerDimensionsUpdated()method 
public function containerDimensionsUpdated(newWidth:Number, newHeight:Number):void

Called by MediaWrapper as notification that its size has changed.

Parameters
newWidth:Number
 
newHeight:Number
contentDimensionsUpdated()method 
protected function contentDimensionsUpdated():void

Called when we know the true size of the content. Subclasses may override and use this opportunity to do their thing, too.

createVideoUI()method 
protected function createVideoUI(player:VideoPlayer):DisplayObject

Create the actual display for the VideoPlayer.

Parameters
player:VideoPlayer

Returns
DisplayObject
didShowNewMedia()method 
protected function didShowNewMedia():void

A place where subclasses can configure things after we've setup new media.

getContentHeight()method 
public function getContentHeight():int

Get the height of the content, bounded by the maximum.

Returns
int
getContentWidth()method 
public function getContentWidth():int

Get the width of the content, bounded by the maximum.

Returns
int
getContext()method 
protected function getContext(url:String):LoaderContext

Return the LoaderContext that should be used to load the media at the specified url.

Parameters
url:String

Returns
LoaderContext
getMaskRectangle()method 
protected function getMaskRectangle():Rectangle

Get the mask area, or null if no mask is needed.

Returns
Rectangle
getMaxContentHeight()method 
public function getMaxContentHeight():int

Get the maximum allowable height for our content.

Returns
int
getMaxContentWidth()method 
public function getMaxContentWidth():int

Get the maximum allowable width for our content.

Returns
int
getMedia()method 
public function getMedia():DisplayObject

Get the media. If the media was loaded using a URL, this will likely be the Loader object holding the real media.

Returns
DisplayObject
getMediaScaleX()method 
public function getMediaScaleX():Number

Get the X scaling factor to use on the actual media.

Returns
Number
getMediaScaleY()method 
public function getMediaScaleY():Number

Get the Y scaling factor to use on the actual media.

Returns
Number
getSecurityDomain()method 
protected function getSecurityDomain(imageURL:String):SecurityDomain

Return the security domain to use for the specified image url.

Parameters
imageURL:String

Returns
SecurityDomain
handleComplete()method 
protected function handleComplete(event:Event):void

Callback function to receive COMPLETE events for swfs or images.

Parameters
event:Event
handleError()method 
protected function handleError(event:ErrorEvent):void

A callback to receive IO_ERROR and SECURITY_ERROR events.

Parameters
event:ErrorEvent
handleInit()method 
protected function handleInit(event:Event):void

Handles the INIT event for content loaded with a Loader.

Parameters
event:Event
handleProgress()method 
protected function handleProgress(event:ProgressEvent):void

A callback to receive PROGRESS events.

Parameters
event:ProgressEvent
handleShutdownOnRemove()method 
protected function handleShutdownOnRemove(event:Event):void

Handle shutting us down when we're removed. Only called if setShutdownOnRemove() was enabled.

Parameters
event:Event
hitTestPoint()method 
public override function hitTestPoint(x:Number, y:Number, shapeFlag:Boolean = false):Boolean

Note: This method is NOT used in normal mouseOver calculations. Normal mouseOver stuff seems to be completely broken for transparent images: the transparent portion is a 'hit'. I've (Ray) tried just about everything to fix this, more than once. But if someone oescall this method (we do, in whirled), then attempt to do the right thing.

Parameters
x:Number
 
y:Number
 
shapeFlag:Boolean (default = false)

Returns
Boolean
initLoader()method 
protected function initLoader():Loader

Initialize a Loader as our _media, and configure it however needed to prepare loading user content.

Returns
Loader
isContentInitialized()method 
public function isContentInitialized():Boolean

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.

Returns
Boolean
isImage()method 
protected function isImage(url:String):Boolean

Does the specified url represent an image?

Parameters
url:String

Returns
Boolean
removeListeners()method 
protected function removeListeners(info:LoaderInfo):void

Remove our listeners from the LoaderInfo object.

Parameters
info:LoaderInfo
setMedia()method 
public function setMedia(url:String):void

Configure the media to display.

Parameters
url:String
setMediaBytes()method 
public function setMediaBytes(bytes:ByteArray):void

Set the media to display as a ByteArray.

Parameters
bytes:ByteArray
setMediaClass()method 
public function setMediaClass(clazz:Class):void

Configure our media as an instance of the specified class.

Parameters
clazz:Class
setMediaObject()method 
public function setMediaObject(disp:DisplayObject):void

Configure an already-instantiated DisplayObject as our media.

Parameters
disp:DisplayObject
setShutdownOnRemove()method 
public function setShutdownOnRemove(enable:Boolean = true):void

Sets whether this MediaContainer automatically shuts down when removed from the stage. By default this is not enabled.

Parameters
enable:Boolean (default = true)
setupBrokenImage()method 
protected function setupBrokenImage(w:int = -1, h:int = -1):void

Display a 'broken image' to indicate there were troubles with loading the media.

Parameters
w:int (default = -1)
 
h:int (default = -1)
setupSwfOrImage()method 
protected function setupSwfOrImage(url:String):void

Configure this sprite to show an image or flash movie.

Parameters
url:String
setupVideo()method 
protected function setupVideo(url:String):void

Configure this sprite to show a video.

Parameters
url:String
showNewMedia()method 
protected function showNewMedia(url:String):voidParameters
url:String
shutdown()method 
public function shutdown(completely:Boolean = true):void

Unload the media we're displaying, clean up any resources.

Parameters
completely:Boolean (default = true) — if true, we're going away and should stop everything. Otherwise, we're just loading up new media.
shutdownMedia()method 
protected function shutdownMedia():void

Do whatever is necessary to shut down the media.

startedLoading()method 
protected function startedLoading():void

Called when we've started loading new media. Will not be called for new media that does not require loading.

stoppedLoading()method 
protected function stoppedLoading():void

Called when we've stopped loading, which may be as a result of completion, an error while loading, or early termination.

toString()method 
public override function toString():String

Returns
String
updateContentDimensions()method 
protected function updateContentDimensions(ww:int, hh:int):void

Called during loading as we figure out how big the content we're loading is.

Parameters
ww:int
 
hh:int
updateLoadingProgress()method 
protected function updateLoadingProgress(soFar:Number, total:Number):void

Update the graphics to indicate how much is loaded.

Parameters
soFar:Number
 
total:Number
willShowNewMedia()method 
protected function willShowNewMedia():void

A place where subclasses can initialize things prior to showing new media.

Event detail
completeevent 
Event object type: flash.events.Event

Dispatched when we've shown new media.

initevent  
Event object type: flash.events.Event

Dispatched when we've initialized our content. This is merely a redispatch of the INIT event we get from the loader.

mediaSizeKnownevent  
Event object type: com.threerings.util.ValueEvent

Dispatched when the size of the media being loaded is known.

unloadevent  
Event object type: flash.events.Event

Dispatched when we've unloaded our content... always. The LoaderInfo's UNLOAD event is only dispatched if the INIT event has already been dispatched and not if you cancel a load before it INIT.

Constant detail
logconstant
protected static const log:Log

A log instance that can be shared by sprites.

SIZE_KNOWNconstant 
public static const SIZE_KNOWN:String = "mediaSizeKnown"

A ValueEvent we dispatch when our size is known. Value: [ width, height ].