LS.ComponentContainer Class
ComponentContainer class allows to add component based properties to any other class
Constructor
LS.ComponentContainer
()
Item Index
Methods
Methods
addComponent
-
component
Adds a component to this node. (maybe attach would been a better name)
Parameters:
-
component
Object
Returns:
component added
broadcastMessage
-
method_name
-
params
executes the method with a given name in all the components and its children
Parameters:
-
method_name
Stringthe name of the function to execute in all components (in string format)
-
params
Arrayarray with every parameter that the function may need
configureComponents
-
info
Adds a component to this node.
Parameters:
-
info
Objectobject containing all the info from a previous serialization
findComponent
-
component
Returns a list of components matching the search, it search in the node and child nodes
Parameters:
-
component
Class | Stringthe component class or the class name
Returns:
an array with all the components of the same class
getComponent
-
component_class
-
index
Returns the first component of this container that is of the same class
Parameters:
-
component_class
Object | Stringthe class to search a component from (could be the class or the name)
-
index
Number[optional] if you want the Nth component of this class
getComponentByIndex
-
component
Returns the component at index position
Parameters:
-
component
Object
getComponentByUId
-
uid
Returns the component with the given uid
Parameters:
-
uid
Stringthe uid to search
getComponents
()
Array
returns an array with all the components
Returns:
all the components
getIndexOfComponent
-
position
Returns the position in the components array of this component
Parameters:
-
position
Numberin the array, -1 if not found
hasComponent
-
component_class
-
search_missing
Returns if the container has a component of this class
Parameters:
-
component_class
String | Classthe component to search for, could be a string or the class itself
-
search_missing
Boolean[optional] true if you want to search in the missing components too
processActionInComponents
-
method_name
-
params
-
skip_scripts
executes the method with a given name in all the components
Parameters:
-
method_name
Stringthe name of the function to execute in all components (in string format)
-
params
Arrayarray with every parameter that the function may need
-
skip_scripts
Boolean[optional] skip scripts
removeAllComponents
-
component
Removes all components from this node.
Parameters:
-
component
Object
removeComponent
-
component
Removes a component from this node.
Parameters:
-
component
Object
requireComponent
-
component_class
-
data
Ensures this node has a component of the specified class, if not it creates one and attaches it
Parameters:
-
component_class
Object | Stringthe class to search a component from (could be the class or the name)
-
data
Object[optional] the object to configure the component from
Returns:
the component found or created
requireScript
-
url
Ensures this node has a ScriptFromFile component of the specified script url, if not it creates one and attaches it
Parameters:
-
url
Stringthe url to the script
Returns:
the ScriptFromFile component found or created
serializeComponents
-
o
Adds a component to this node.
Parameters:
-
o
Objectcontainer where the components will be stored
setComponentIndex
-
component
Changes the order of a component
Parameters:
-
component
Object