Packagecom.whirled.avrg
Classpublic class LocalSubControl
InheritanceLocalSubControl Inheritance AbstractSubControl Inheritance AbstractControl Inheritance flash.events.EventDispatcher

Defines actions, accessors and callbacks available on the client only.



Public Properties
 PropertyDefined by
  hitPointTester : Function
[read-only] Returns the AVRG's currently configured hit point tester.
LocalSubControl
  mobSpriteExporter : Function
[read-only] Accesses the previously set mob sprite exporter.
LocalSubControl
Public Methods
 MethodDefined by
 Inherited
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
Registers an event listener.
AbstractControl
 Inherited
doBatch(fn:Function, ... args):void
Execute the specified function as a batch of commands that will be sent to the server together.
AbstractSubControl
  
feedback(msg:String):void
Displays a feedback chat message for the local player only, no other players or observers will see it.
LocalSubControl
  
Retrieves the ID of the member who invited the current player to this game (using the page shown by showInvitePage.
LocalSubControl
  
getInviteToken():String
Retrieves the token, if any, that was used to launch the game.
LocalSubControl
  
getPaintableArea(full:Boolean = true):Rectangle
Returns the bounds of the area on which the AVRG will be drawn.
LocalSubControl
  
getRoomBounds():Array
Get the room bounds in "room pixels".
LocalSubControl
  
hideUI(element:int):void
Request to hide a particular UI element, if showing.
LocalSubControl
 Inherited
isConnected():Boolean
Are we connected and running inside the whirled environment, or has someone just loaded up our SWF by itself?
AbstractSubControl
  
isUIShowing(element:int):Boolean
Is the particular UI element showing?
LocalSubControl
  
locationToPaintable(x:Number, y:Number, z:Number):Point
Converts a 3D room location coordinate to a 2D paintable area coordinate.
LocalSubControl
  
locationToRoom(x:Number, y:Number, z:Number):Point
Converts a 3D room location coordinate to a 2D decor coordinate.
LocalSubControl
  
navigateToURL(url:Object, preferredTarget:String = null):void
Navigate to the specified url, targetting the specified window/tab.
LocalSubControl
  
paintableToLocationAtDepth(p:Point, depth:Number):Array
Converts a paintable area coordinate to a 3D room coordinate by projecting onto a plane parallel to the front wall, intersecting the room at a specified depth.
LocalSubControl
  
paintableToLocationAtHeight(p:Point, height:Number):Array
Converts a paintable area coordinate to a 3D room coordinate by projecting onto a plane parallel to the floor, intersecting the room at a specified height.
LocalSubControl
  
paintableToRoom(p:Point):Point
Converts a paintable area coordinate to a decor coordinate.
LocalSubControl
 Inherited
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
Unregisters an event listener.
AbstractControl
  
roomToPaintable(p:Point):Point
Converts a decor coordinate to a paintable area coordinate.
LocalSubControl
  
setHitPointTester(tester:Function):void
Configures the AVRG with a function to call to determine which pixels are alive for mouse purposes and which are not.
LocalSubControl
  
setMobSpriteExporter(exporter:Function):void
Sets the function that will manufacture DisplayObject instances on the client when mobs are spawned by the server agent.
LocalSubControl
  
setRoomViewBounds(roomBounds:Rectangle):void
Set the boundaries of the room view in paintable coordinates, or null to have the room try to use the full area (default).
LocalSubControl
  
setShowChrome(show:Boolean):void
Hide or show the chrome, the UI for Whirled itself.
LocalSubControl
  
showInvitePage(defmsg:String, token:String = ""):void
Instructs the game client to open the game invite page, allowing the player to invite friends to play this game.
LocalSubControl
  
showPage(token:String):Boolean
Shows the Whirled page identified by the supplied token.
LocalSubControl
  
showUI(element:int, arg:Object = null):void
Request to show a particular UI element.
LocalSubControl
Events
 EventSummaryDefined by
   Dispatched when the control has been resized.LocalSubControl
 Inherited Event.UNLOAD Dispatched when the SWF using this control has been unloaded.AbstractControl
Property detail
hitPointTesterproperty
hitPointTester:Function  [read-only]

Returns the AVRG's currently configured hit point tester.

Implementation
    public function get hitPointTester():Function

See also

mobSpriteExporterproperty 
mobSpriteExporter:Function  [read-only]

Accesses the previously set mob sprite exporter.

Implementation
    public function get mobSpriteExporter():Function

See also

Method detail
feedback()method
public function feedback(msg:String):void

Displays a feedback chat message for the local player only, no other players or observers will see it.

Parameters
msg:String
getInviterMemberId()method 
public function getInviterMemberId():int

Retrieves the ID of the member who invited the current player to this game (using the page shown by showInvitePage. Returns 0 if the player did not start the game via an invite link.

Returns
int
getInviteToken()method 
public function getInviteToken():String

Retrieves the token, if any, that was used to launch the game. If the player entered into the game via a URL that contained a token (provided by the game via showInvitePage), this will return that token, otherwise null. Note that the invitations are not managed securely, it would be trivial for someone to modify a URL to specify a different token, so appropriate checks should be made.

Returns
String
getPaintableArea()method 
public function getPaintableArea(full:Boolean = true):Rectangle

Returns the bounds of the area on which the AVRG will be drawn. This value changes when the browser is resized, and when the player moves to another room. A null value may be returned if the paintable area is not currently defined, for example if the player has left a room and the new room is not yet loaded.

Parameters
full:Boolean (default = true) — If true (the default), returns the entire paintable area. If false, returns the area occupied by the room's decor, which can be smaller than the entire paintable area in narrow rooms, or when the room view is zoomed out.

Returns
Rectangle — a Rectangle containing the bounds of the paintable area, or null if the area is not defined, for example if full=false and the player is not in a room.

See also

getRoomBounds()method 
public function getRoomBounds():Array

Get the room bounds in "room pixels". This will be a 3-element array corresponding to [ width, height, depth ]. These values are otreal pixels. Rather, if an avatar is 100 pixels wide and a room is 700 pixels wide, then the avatar should be able to span 7 across, whether it's in the front of the room or the rear. TODO: This is not yet here. It's

Returns
Array
hideUI()method 
public function hideUI(element:int):void

Request to hide a particular UI element, if showing.

Parameters
element:int
isUIShowing()method 
public function isUIShowing(element:int):Boolean

Is the particular UI element showing?

Parameters
element:int

Returns
Boolean
locationToPaintable()method 
public function locationToPaintable(x:Number, y:Number, z:Number):Point

Converts a 3D room location coordinate to a 2D paintable area coordinate. A null value may be returned if the room is not currently well defined, for example if the player has left a room and the new room is not yet loaded.

"3D room" is a an absolute coordinate system used by the Whirled server and server agents to specify an unambiguous position within the room's space.

"Decor" or "2D room" is a two dimensional system that measures the location in pixels relative to the top-left corner of the room decor graphics. This removes all effects of stretching and scrolling so is absolute for all clients.

Parameters
x:Number
 
y:Number
 
z:Number

Returns
Point

See also

locationToRoom()method 
public function locationToRoom(x:Number, y:Number, z:Number):Point

Converts a 3D room location coordinate to a 2D decor coordinate. A null value may be returned if the room is not currently well defined, for example if the player has left a room and the new room is not yet loaded.

"3D room" is a an absolute coordinate system used by the Whirled server and server agents to specify an unambiguous position within the room's space.

"Decor" or "2D room" is a two dimensional system that measures the location in pixels relative to the top-left corner of the room decor graphics. This removes all effects of stretching and scrolling so is absolute for all clients.

Parameters
x:Number
 
y:Number
 
z:Number

Returns
Point

See also

navigateToURL()method 
public function navigateToURL(url:Object, preferredTarget:String = null):void

Navigate to the specified url, targetting the specified window/tab. Normally, the security boundary in which your game runs prevents you from using flash.net.navigateToURL() with a target of "_self" or "_top" (which would unload whirled and your game!), but this method will try to do its best to let you do that. It will fall back to loading the url with a blank target, if possible, or if your game is not 'approved'.

Note: be extremely careful with how you construct this URL and be aware that if partially based on user input, the input should be thoroughly scrubbed to prevent surprises.

Note: using a non-null target is only allowed for approved games, and will silently fall back to null for unapproved games. The approval process is still being developed.

Parameters
url:Object — a URLRequest or String.
 
preferredTarget:String (default = null) — the window or tab into which to load. Null will load into a new window/tab, or you specify a name, or use one of the special values: "_top", "_parent", or "_self".
paintableToLocationAtDepth()method 
public function paintableToLocationAtDepth(p:Point, depth:Number):Array

Converts a paintable area coordinate to a 3D room coordinate by projecting onto a plane parallel to the front wall, intersecting the room at a specified depth. This type of functionality is useful for converting mouse position into 3D room location at some constant depth. The result is not constrained to be inside the room unit box.

"Paintable area" is a 2D pixel coordinate system that is relative to the parent display object of your game's interface and therefore useful for actually setting the x and y properties of your top-level user interface display object.

"3D room" is a an absolute coordinate system used by the Whirled server and server agents to specify an unambiguous position within the room's space.

Parameters
p:Point — location in paintable area coordinate space
 
depth:Number — Z position of the intersection wall, in room coordinate space.

Returns
Array — an array containing [ x, y, z ] (with z value equal to depth), or null if no valid location was found.

See also

paintableToLocationAtHeight()method 
public function paintableToLocationAtHeight(p:Point, height:Number):Array

Converts a paintable area coordinate to a 3D room coordinate by projecting onto a plane parallel to the floor, intersecting the room at a specified height. This type of functionality is useful for converting mouse position into 3D room location at some constant height. The result is not constrained to be inside the room unit box.

"Paintable area" is a 2D pixel coordinate system that is relative to the parent display object of your game's interface and therefore useful for actually setting the x and y properties of your top-level user interface display object.

"3D room" is a an absolute coordinate system used by the Whirled server and server agents to specify an unambiguous position within the room's space.

Parameters
p:Point — location in room coordinate space
 
height:Number — Y position of the intersection wall, in room coordinate space.

Returns
Array — an array containing [ x, y, z ] (with y value equal to height) or null if no valid location was found.

See also

paintableToRoom()method 
public function paintableToRoom(p:Point):Point

Converts a paintable area coordinate to a decor coordinate. A null value may be returned if the room is not currently well defined, for example if the player has left a room and the new room is not yet loaded.

"Paintable area" is a 2D pixel coordinate system that is relative to the parent display object of your game's interface and therefore useful for actually setting the x and y properties of your top-level user interface display object.

"Decor" or "2D room" is a two dimensional system that measures the location in pixels relative to the top-left corner of the room decor graphics. This removes all effects of stretching and scrolling so is absolute for all clients.

Parameters
p:Point

Returns
Point

See also

roomToPaintable()method 
public function roomToPaintable(p:Point):Point

Converts a decor coordinate to a paintable area coordinate. A null value may be returned if the room is not currently well defined, for example if the player has left a room and the new room is not yet loaded.

"Decor" or "2D room" is a two dimensional system that measures the location in pixels relative to the top-left corner of the room decor graphics. This removes all effects of stretching and scrolling so is absolute for all clients.

"Paintable area" is a 2D pixel coordinate system that is relative to the parent display object of your game's interface and therefore useful for actually setting the x and y properties of your top-level user interface display object.

Parameters
p:Point

Returns
Point

See also

setHitPointTester()method 
public function setHitPointTester(tester:Function):void

Configures the AVRG with a function to call to determine which pixels are alive for mouse purposes and which are not. By default, all non-transparent pixels will capture the mouse. The prototype for this method is identical to what the Flash API establishes in DisplayObject:

        function testHitPoint(x :Number, y :Number, shapeFlag :Boolean) :Boolean
     

Parameters
tester:Function

See also

flash.display.DisplayObject.hitTestPoint()
setMobSpriteExporter()method 
public function setMobSpriteExporter(exporter:Function):void

Sets the function that will manufacture DisplayObject instances on the client when mobs are spawned by the server agent. The function must take the string type of the requested mob and return a DisplayObject:

        function createMobSprite (type :String) :DisplayObject;
     

Once created, the mob will be drawn in the room until the server agent despawns it. Clients should not attempt to remove the sprite. Each mob in a room has a corresponding MobSubControlClient. Games that use mobs should call this function during initialization so that if the player is joining an in-progress game, all the previously spawned mobs will be created.

Parameters
exporter:Function

See also

setRoomViewBounds()method 
public function setRoomViewBounds(roomBounds:Rectangle):void

Set the boundaries of the room view in paintable coordinates, or null to have the room try to use the full area (default).

Parameters
roomBounds:Rectangle
setShowChrome()method 
public function setShowChrome(show:Boolean):void

Hide or show the chrome, the UI for Whirled itself.

Note: this method is only allowed for approved games, and will silently fail for unapproved games. The approval process is still being developed.

Parameters
show:Boolean
showInvitePage()method 
public function showInvitePage(defmsg:String, token:String = ""):void

Instructs the game client to open the game invite page, allowing the player to invite friends to play this game.

Parameters
defmsg:String — Default message that will be included along with the game's URL when sent to the player's friends.
 
token:String (default = "") — Optional token that will be included on the URL and eventually passed back to the game when an invited friend goes to the URL. This allows the game to start in a different state than usual.
showPage()method 
public function showPage(token:String):Boolean

Shows the Whirled page identified by the supplied token.

Parameters
token:String — the token that identifies the page to be shown. This is not the full URL, just the part after http://www.whirled.com/#. For example: passing "me" would show the Me page. Passing "shop-l_5_343" would show the shop page for the Kawaii Knight avatar.

Returns
Boolean — true if the page was shown, false if it could not be shown for some reason.
showUI()method 
public function showUI(element:int, arg:Object = null):void

Request to show a particular UI element. Some of this can be accomplished presently by calling showPage, but that might not always work. If we move inventory into an in-flash popup, for example, then this method should always work, but showPage may cease to exist (although maybe we'll analyze the args and make it work).

Parameters
element:int — a constant from
 
arg:Object (default = null) — an element-specific argument, or an Object hash containing multiple args. See the documentation for each constant in UIConstants.

See also

Event detail
sizeChangedevent 
Event object type: com.whirled.avrg.AVRGameControlEvent
AVRGameControlEvent.type property = com.whirled.avrg.AVRGameControlEvent.SIZE_CHANGED

Dispatched when the control has been resized.

An event type dispatched when the control has been resized.
name - not used
value - not used

See also