com.theoworlds.builder.MapObject

base class for all map objects classes on the map : Tile, Furniture, Character

Summary
com.theoworlds.builder.MapObjectbase class for all map objects classes on the map : Tile, Furniture, Character
Variables
_IDMapObject id:Number
__worldreference to a the World object
tileXposition on the map (column:Number)
tileYposition on the map (row:{Number})
libIDid:Number of a Library for a map
libItemIDid:Number for an object from this library
libFrameframe/phase:Number (if there are multiple possible directions), by default == 1
_actionsname{name:String, [attributes:*]}
_currentActionNamecharacter animation name:String (curent)
_elevationthe height:Number of the object
_stackablestacks on top of other tiles, taking elevation in consideration
_walkableflag(:Boolean) that tells if characters(Character) can walk on top of this object
_targetMCMovieClip that contains the MapObject._spriteMC
_spriteMCMovieClip in which MapObject is located
_addedMovieClipused for loading symbols from Library
_spriteMCNamesets the World when activating the movieclip (if it’s present)
_spriteMCZOrderZ--order of the MovieClip, if it’s present
MARKER_DEPTHthe depth(:Number) of the debug layer
GRID_DEPTHthe depth(:Number) of the grid layer
LOADED_DEPTHthe depth(:Number) of the loaded symbol
Functions
MapObject
initif there is a link to the Library -- load the symbol extended and modified in the inherited classes -- for example: the Tiles position is calculated differently from Furniture one, that why MapObject._spriteMC position has to be adjusted
loadMovieloads the symbol (the movie) from the Library //TODO -- rewrite it for floor tiles, to get from Library not the url but the bitmap directly and simply copy it into the floor (since it will not change later) //TODO -- for furniture, it it’s not animated, try the same -- it will optimize the engine, though with Tiles it will give a bigger effect
onLoadInitLibrarySymbolcalled by MovieClipLoader.onLoadInit
onLoadCompleteLibrarySymbolcalled by MovieClipLoader.onLoadComplete to be implemented in the child classes
createSpriteMCcreates the base MovieClip into wich a Library symbol is loaded
removeSpriteMCremoves the MapObject._spriteMC
swapDepthsworks like MovieClip.swapDepths
clearcleans the assets
getActionsMapObject._actions
initActionsinitializes the actions of a given object
isValidActionchecks if the action is valid
getActionName
getAllowedActionDirections
getAction
attachActionattach action to an object if action with such name exists -- it will be overwritten
detachActiondetach an action from an object
Properties
currentActionNamesets the current action the action has to be registered in _actions or during the initialization (from the symbol library), or from the XML map, or through the MapObject.attachAction(action:Object) method
currentActionName-- the name(:String) of the current action
worldused by CharacterLogic
IDobject id(:Number)
spriteMC-- “base” MovieClip of MapObject
Functions
setWorldsets the reference to the World.

Variables

_ID

private var _ID: Number

MapObject id:Number

__world

private static var __world: World

reference to a the World object

tileX

public var tileX: Number

position on the map (column:Number)

tileY

public var tileY: Number

position on the map (row:{Number})

libID

var libID: Number

id:Number of a Library for a map

libItemID

var libItemID: Number

id:Number for an object from this library

libFrame

var libFrame: Number

frame/phase:Number (if there are multiple possible directions), by default == 1

_actions

private var _actions: Object

name{name:String, [attributes:*]}

The details

1 -- this is an object 2 -- the action name is stored and is called like this -- _actions[name] 3 -- parametters are set in this way: _actions[name].parameter1 _actions[name].parameter2 _actions[name].parameter3....  4 -- one parametter is mandatory: а -- name:String -- _actions[name].name 5 -- the rest are optional: a -- frames -- the number of action animation frames (1 by default) b -- movable -- a flag that tells in this action is movable or now (walking vs dancing on the spot, for example) (0 by default) c -- nonStop -- a flag that shows if the animation is looping (repeating again and again) (0 by default) d -- snapToAction -- works only with movable=1, a flag that tells if the character starts the action right away or finishes his movement first (like sitting on a chair, instead of walking on it first) (0 by default) e -- usesLeftRightSteps -- a flag that tells if the movement action uses left/right step sequences.  (1 by default) f -- allowedActionDirs -- the directions in which the action is available (“1,2,3,4,5,6,7,8” by default -- all the directions)

the parametters are stored as Strings.  Later, the values are brought to the right type (ex: frames --> Number) New custom functions can be added, to make the access to the parametters easy example -- Character.getActionFrameNumber(action:String):Number { return Number( _actions[action].frames ); }

in *.FLA with the character the keyframes have to be named in this way

actionName+”_”+direction check the documentation for more details

_currentActionName

private var _currentActionName: String

character animation name:String (curent)

_elevation

private var _elevation: Number

the height:Number of the object

_stackable

private var _stackable: Boolean

stacks on top of other tiles, taking elevation in consideration

_walkable

private var _walkable: Boolean

flag(:Boolean) that tells if characters(Character) can walk on top of this object

_targetMC

private var _targetMC: MovieClip

MovieClip that contains the MapObject._spriteMC

_spriteMC

private var _spriteMC: MovieClip

MovieClip in which MapObject is located

_addedMovieClip

private var _addedMovieClip: MovieClip

used for loading symbols from Library

_spriteMCName

private var _spriteMCName: String

sets the World when activating the movieclip (if it’s present)

_spriteMCZOrder

private var _spriteMCZOrder: Number

Z--order of the MovieClip, if it’s present

MARKER_DEPTH

private static var MARKER_DEPTH: Number

the depth(:Number) of the debug layer

GRID_DEPTH

private static var GRID_DEPTH: Number

the depth(:Number) of the grid layer

LOADED_DEPTH

private static var LOADED_DEPTH: Number

the depth(:Number) of the loaded symbol

Functions

MapObject

public function MapObject(target: MovieClip,
spriteMCName: String,
spriteMCZOrder: Number,
tileX: Number,
tileY: Number,
mos: MapObjectSettings,
skipValidation: Boolean)

Parameters

targetMovieClip to wich MapObject is attached
spriteMCNamename(:String) of MovieClip if it’s created
spriteMCZOrderz--order(:Number) of MovieClip, if it’s created
tileXtile row(:Number) (to be removed since it’s in MapObjectSettings?)
tileYtile column(:Number)
mos(MapObjectSettings)

init

private function init(mos: MapObjectSettings):Void

if there is a link to the Library -- load the symbol extended and modified in the inherited classes -- for example: the Tiles position is calculated differently from Furniture one, that why MapObject._spriteMC position has to be adjusted

Parameters

mos(MapObjectSettings)

loadMovie

private function loadMovie(mos: MapObjectSettings):Void

loads the symbol (the movie) from the Library //TODO -- rewrite it for floor tiles, to get from Library not the url but the bitmap directly and simply copy it into the floor (since it will not change later) //TODO -- for furniture, it it’s not animated, try the same -- it will optimize the engine, though with Tiles it will give a bigger effect

Parameters

mos(MapObjectSettings) -- it’s passed since more initiation actions may be needed after the loading MapObjectSettings is not saved in the class to save memory -- it can get heavy otherwise

onLoadInitLibrarySymbol

private function onLoadInitLibrarySymbol(mos: MapObjectSettings):Void

called by MovieClipLoader.onLoadInit

onLoadCompleteLibrarySymbol

private function onLoadCompleteLibrarySymbol(mos: MapObjectSettings) : Void

called by MovieClipLoader.onLoadComplete to be implemented in the child classes

Parameters

mos(MapObjectSettings)

createSpriteMC

private function createSpriteMC(x: Number,
y: Number):Void

creates the base MovieClip into wich a Library symbol is loaded

Parameters

x-- integer that sets the x coordinate of a movie clip
y-- integer that sets the y coordinate of a movie clip

removeSpriteMC

private function removeSpriteMC():Void

removes the MapObject._spriteMC

swapDepths

public function swapDepths(depth: Number):Void

works like MovieClip.swapDepths

Parameters

depth(:Number)

clear

public function clear():Void

cleans the assets

to be extended by the child classes

getActions

public function getActions():Object

Returns

MapObject._actions

initActions

private function initActions(mos: MapObjectSettings):Void

initializes the actions of a given object

Parameters

mos(:MapObjectSettings)

isValidAction

private function isValidAction(action: String):Boolean

checks if the action is valid

Parameters

action-- action name(:String)

Returns

true/false

getActionName

private function getActionName(action: Object):String

Parameters

action(:Object)

Returns

action name(:String) if the action is valid

getAllowedActionDirections

public function getAllowedActionDirections(action):Array

Parameters

action(String or Object)

Returns

the directions(:Array) supported by the action, by default returns [1,2,3,4,5,6,7,8]

getAction

public function getAction(action: String):Object

Parameters

action(:String) -- action name

Returns

the action (MapObject._actions) by name.  Each action name has to be unique!  a very heavy function since it makes the copy of the object it is recommended to write separate custom functions for accessing the parametters directly.  Example: Character.getActionFrameNumber(action:String):Number { return Number( _actions[action].frames ); }

attachAction

public function attachAction(action: Object):Void

attach action to an object if action with such name exists -- it will be overwritten

Parameters

action-- Object {name:String[,params:String]}

detachAction

public function detachAction(action: String):Void

detach an action from an object

Parameters

action(:String) -- action name

Properties

currentActionName

public function set currentActionName(action: String):Void

sets the current action the action has to be registered in _actions or during the initialization (from the symbol library), or from the XML map, or through the MapObject.attachAction(action:Object) method

Parameters

action(:String) -- action name

currentActionName

public function get currentActionName():String

Returns

-- the name(:String) of the current action

world

public function get world (): World

used by CharacterLogic

Returns

(World)

ID

public function get ID (): Number

Returns

object id(:Number)

spriteMC

public function get spriteMC():MovieClip

Returns

-- “base” MovieClip of MapObject

Functions

setWorld

public static function setWorld(w: World):Void

sets the reference to the World.  Called once on initialization

Character class -- character/avatar main class
Furniture class - furniture main class
Tile class -- floor tile main class
private var _ID: Number
MapObject id:Number
private static var __world: World
reference to a the World object
World class -- main class that builds an isometric tile--based map
public var tileX: Number
position on the map (column:Number)
public var tileY: Number
position on the map (row:{Number})
var libID: Number
id:Number of a Library for a map
LibraryItem class i- stores and manages a collection of LibraryItem objects organized in sub-libraries - those are map objects like Floor tiles, Furniture and Characters that can be placed on maps
var libItemID: Number
id:Number for an object from this library
var libFrame: Number
frame/phase:Number (if there are multiple possible directions), by default == 1
private var _actions: Object
name{name:String, [attributes:*]}
private var _currentActionName: String
character animation name:String (curent)
private var _elevation: Number
the height:Number of the object
private var _stackable: Boolean
stacks on top of other tiles, taking elevation in consideration
private var _walkable: Boolean
flag(:Boolean) that tells if characters(Character) can walk on top of this object
private var _targetMC: MovieClip
MovieClip that contains the MapObject._spriteMC
private var _spriteMC: MovieClip
MovieClip in which MapObject is located
private var _addedMovieClip: MovieClip
used for loading symbols from Library
private var _spriteMCName: String
sets the World when activating the movieclip (if it’s present)
private var _spriteMCZOrder: Number
Z--order of the MovieClip, if it’s present
private static var MARKER_DEPTH: Number
the depth(:Number) of the debug layer
private static var GRID_DEPTH: Number
the depth(:Number) of the grid layer
private static var LOADED_DEPTH: Number
the depth(:Number) of the loaded symbol
public function MapObject(target: MovieClip,
spriteMCName: String,
spriteMCZOrder: Number,
tileX: Number,
tileY: Number,
mos: MapObjectSettings,
skipValidation: Boolean)
private function init(mos: MapObjectSettings):Void
if there is a link to the Library -- load the symbol extended and modified in the inherited classes -- for example: the Tiles position is calculated differently from Furniture one, that why MapObject._spriteMC position has to be adjusted
private function loadMovie(mos: MapObjectSettings):Void
loads the symbol (the movie) from the Library //TODO -- rewrite it for floor tiles, to get from Library not the url but the bitmap directly and simply copy it into the floor (since it will not change later) //TODO -- for furniture, it it’s not animated, try the same -- it will optimize the engine, though with Tiles it will give a bigger effect
private function onLoadInitLibrarySymbol(mos: MapObjectSettings):Void
called by MovieClipLoader.onLoadInit
private function onLoadCompleteLibrarySymbol(mos: MapObjectSettings) : Void
called by MovieClipLoader.onLoadComplete to be implemented in the child classes
private function createSpriteMC(x: Number,
y: Number):Void
creates the base MovieClip into wich a Library symbol is loaded
private function removeSpriteMC():Void
removes the MapObject._spriteMC
public function swapDepths(depth: Number):Void
works like MovieClip.swapDepths
public function clear():Void
cleans the assets
public function getActions():Object
MapObject._actions
private function initActions(mos: MapObjectSettings):Void
initializes the actions of a given object
private function isValidAction(action: String):Boolean
checks if the action is valid
private function getActionName(action: Object):String
public function getAllowedActionDirections(action):Array
public function getAction(action: String):Object
public function attachAction(action: Object):Void
attach action to an object if action with such name exists -- it will be overwritten
public function detachAction(action: String):Void
detach an action from an object
public function set currentActionName(action: String):Void
sets the current action the action has to be registered in _actions or during the initialization (from the symbol library), or from the XML map, or through the MapObject.attachAction(action:Object) method
public function get world (): World
used by CharacterLogic
CharacterLogic class - stores the character logic.
public function get ID (): Number
object id(:Number)
public function get spriteMC():MovieClip
-- “base” MovieClip of MapObject
public static function setWorld(w: World):Void
sets the reference to the World.
This class and its inheritants is used to organize the map object parameters
Close