NamespaceJS Class Reference
Inherits from | JavaScript Object |
Location | aphid.js |
Overview of Tasks
Attributes
- Name
-
gcFrequency
Controls the frequency of the explicit garbage collection which is invoked internally.
-
onload
An event handler for the load event of the main JavaScript file
- Type
-
int
-
function
- Writability
-
readwrite
-
readwrite
Functions
- Signature
-
gc()
Prompts an explicit garbage collection.
-
includeFile(filename)
Includes and evaluates a JavaScript file
-
includeScript(script)
- Return Type
-
bool
-
object
-
object
Attributes
gcFrequency
Controls the frequency of the explicit garbage collection which is invoked internally.
readwrite
int
gcFrequencyDiscussion
Default value is 1
, which means garbage collection is invoked after rendering one frame. Increasing it can reduce the invocation count of explicit GC, which may increase the overall performance a bit.
onload
An event handler for the load event of the main JavaScript file
readwrite
function
onloadDiscussion
It’s recommended to put the game initialization logic inside this event handler, which guarantees the whole JavaScript file has been evaluated completely.
Notes: Although it works fine in current release of OpenAphid if the initialization logic is inside the global scope, it may break in a future release as it’s planned to put the evaluation process in a separate thread.
Functions
gc()
Prompts an explicit garbage collection.
bool
gc()Return Value: bool
Returns true
if a GC is performed.
includeFile(filename)
Includes and evaluates a JavaScript file
object
includeFile(string
filename)Parameters
string
filename
Return Value: object
Discussion
The behavior of this function is similiar to the <script>
tag of HTML.
The evaluation is performed on the global scope; and it’s a synchronized process which blocks the execution of the file contains it.
If the Develop Mode
of OpenAphid is enabled, the specified file will always be fecthed from remote web server.