com.theoworlds.builder.lib.Library

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

Version

1.0

Author

© TheoWorlds.com, 2007-2009.

Summary
com.theoworlds.builder.lib.LibraryLibraryItem 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
Variables
_librariesa 2D array that stores different libaries and their items first parametter is the unique library ID and the second is the ID of the item in this library this array of libaries stores arrays of LibraryItem objects -- the links to them -- LibraryItem to get to the information about a LibraryItem object (info about a map object) we use lib_arr[libID--1][libSymbolId--1]
_librariesInfowe need those parametters for the Map Editor so we can display all the info in the preview panel
__instancejust one Library object can exist (Singleton).
_externalListeners_arrexternal listeners subscribed to the “onEndParsing” event -- called when the libraries are loaded and parced
Functions
getInstanceSingleton class
Libraryconstructor
getSymbolURL
getLibraryItem
getLibraryreturns an array with all the items of one sub--library.
getLibraryInfoarray of objects [{id:Number, url:String}] The libraries are located in the_libraries array, in order of their ID.
addLibrary//OPT to pass or not the ID? 
addListenersubscribes event listeners
removeListenerunsubscribes event listeners
dispatchEvent
parseLibraryparces the library XML file
addItemadds at item to the libraries array
addLibraryInfoads the info about the loaded library to the libInfo_arr

Variables

_libraries

private var _libraries: Array

a 2D array that stores different libaries and their items first parametter is the unique library ID and the second is the ID of the item in this library this array of libaries stores arrays of LibraryItem objects -- the links to them -- LibraryItem to get to the information about a LibraryItem object (info about a map object) we use lib_arr[libID--1][libSymbolId--1]

_librariesInfo

private var _librariesInfo: Array

we need those parametters for the Map Editor so we can display all the info in the preview panel

{id:Number, url:String}

__instance

private static var __instance: Library

just one Library object can exist (Singleton).  This variable stores the link to it

_externalListeners_arr

private var _externalListeners_arr: Array

external listeners subscribed to the “onEndParsing” event -- called when the libraries are loaded and parced

Functions

getInstance

public static function getInstance():Library

Singleton class

Library

private function Library()

constructor

getSymbolURL

public static function getSymbolURL(libID: Number,
libItemlID: Number):String

Parameters

libID
symbolID

Returns

return the location of the library item graphic file

getLibraryItem

public static function getLibraryItem(libID: Number,
libItemID: Number):LibraryItem

Parameters

libID
symbolID

Returns

returns the ORIGINAL map item object -- do not modify its properties on the fly, unless really needed

getLibrary

public static function getLibrary(libID: Number):Array

returns an array with all the items of one sub--library. use for read only, DO NOT modify it outside used by Map Editor ONLY

Parameters

index-- ID of the Library -- also the index in the 2D array (first index)

Returns

<LibraryItem>Array

getLibraryInfo

public static function getLibraryInfo():Array

Returns

array of objects [{id:Number, url:String}] The libraries are located in the_libraries array, in order of their ID.  So if it’s needed to get to the right library, we may need to go through 1000 items This way we access it as a database

addLibrary

public function addLibrary(source):Void

//OPT to pass or not the ID?  May be just use the ID from its XML?

Parameters

id
url-- the XML file location with library info the XML type of parametter was added // TODO -- may be adding the parametters as an unlimited list... 

addListener

public function addListener(o: Object):Void

subscribes event listeners

Parameters

o-- listener

removeListener

public function removeListener(o):Void

unsubscribes event listeners

Parameters

o-- listener

dispatchEvent

private function dispatchEvent(event: String):Void

Parameters

eventfires an event notifier

parseLibrary

private function parseLibrary(success: Boolean,
lib: XML,
url: String):Void

parces the library XML file

Parameters

success-- Boolean -- the result of the loading/parcing
lib-- XML
result-- link to the this.lib_arr[libID] -- the array with library data (array of library items/symbols)

addItem

private function addItem(libID: Number,
itemID: Number,
li: LibraryItem):Void

adds at item to the libraries array

Parameters

libID
itemID
li(LinraryItem)

addLibraryInfo

private function addLibraryInfo(o: Object):Void

ads the info about the loaded library to the libInfo_arr

Parameters

oObject {id:Number, url:String}
private var _libraries: Array
a 2D array that stores different libaries and their items first parametter is the unique library ID and the second is the ID of the item in this library this array of libaries stores arrays of LibraryItem objects -- the links to them -- LibraryItem to get to the information about a LibraryItem object (info about a map object) we use lib_arr[libID--1][libSymbolId--1]
if we need variations of the same symbol (map object), for example a chair -- make a version of this chair that is sittable and another that is not, we can do it in two different ways: 1 -- we can create two librariy items (symbols) that look the SAME (point to the same SWF file), but have one single (or more) different attributes
private var _librariesInfo: Array
we need those parametters for the Map Editor so we can display all the info in the preview panel
private static var __instance: Library
just one Library object can exist (Singleton).
private var _externalListeners_arr: Array
external listeners subscribed to the “onEndParsing” event -- called when the libraries are loaded and parced
public static function getInstance():Library
Singleton class
private function Library()
constructor
public static function getSymbolURL(libID: Number,
libItemlID: Number):String
public static function getLibraryItem(libID: Number,
libItemID: Number):LibraryItem
public static function getLibrary(libID: Number):Array
returns an array with all the items of one sub--library.
public static function getLibraryInfo():Array
array of objects [{id:Number, url:String}] The libraries are located in the_libraries array, in order of their ID.
public function addLibrary(source):Void
//OPT to pass or not the ID? 
public function addListener(o: Object):Void
subscribes event listeners
public function removeListener(o):Void
unsubscribes event listeners
private function dispatchEvent(event: String):Void
private function parseLibrary(success: Boolean,
lib: XML,
url: String):Void
parces the library XML file
private function addItem(libID: Number,
itemID: Number,
li: LibraryItem):Void
adds at item to the libraries array
private function addLibraryInfo(o: Object):Void
ads the info about the loaded library to the libInfo_arr
Close