The script element contains JavaScript code that is
executed when the application is loaded. This element must be at the
canvas level; that is, it cannot be contained within any
subordinate tag. If the src attribute is
present, it names a JavaScript file whose contents are compiled into
the application.
In the example below, we add a method to the built-in
Array class that will let us find the index of
elements in an array. Note that Array.find uses
=== for finding, so that two objects that are similar
will not be confused. This is why looking for {example:
'sneaky'} finds nothing, whereas looking for
sneaky succeeds.
<canvas debug="true" height="200" width="400">
<debug y="5%" height="90%"/>
<script>
// Add a find method to Array
Array.prototype.find = function ( what ) {
for (i in this ) {
if (this[i] === what) {
return i;
}
}
}
sneaky = {example: 'sneaky'};
tryit = ['foo', 42, sneaky, Math.PI, false];
Debug.format("42 is at: %s\n", tryit.find(42));
Debug.format("false is at: %s\n", tryit.find(false));
Debug.format("'bar' is at: %s\n", tryit.find('bar'));
Debug.format("{example: 'sneaky'} is at: %s\n", tryit.find({example: 'sneaky'}));
Debug.format("sneaky is at: %s\n", tryit.find(sneaky));
</script>
</canvas>
| Name | Type (tag) | Type (js) | Default | Category |
|---|---|---|---|---|
src
|
string | String | initialize-only | |
The pathname of a Javascript file. This pathname is resolved
relative to the file that contains the
<script> element.
|
||||
classroot, cloneManager, datapath, defaultplacement, id, ignoreplacement, immediateparent, inited, initstage, name, nodeLevel, options, parent, placement, subnodes
Methods
animate, applyConstraint, applyConstraintMethod, applyData, childOf, completeInstantiation, construct, createChildren, dataBindAttribute, destroy, determinePlacement, getAttribute, getOption, getUID, init, lookupSourceLocator, releaseConstraint, releaseConstraintMethod, searchImmediateSubnodes, searchSubnodes, setData, setDatapath, setOption, setSelected, updateData
Events
Copyright © 2002-2008 Laszlo Systems, Inc. All Rights Reserved. Unauthorized use, duplication or distribution is strictly prohibited. This is the proprietary information of Laszlo Systems, Inc. Use is subject to license terms.