New
Keyword in both Lingo and JavaScript that is used to create an instance of an object from a script or Xtra or new members.
Syntax:
Creating a member (type is a symbol or string for the member type):
new(type) new(type, castLib whichCast) new(type, member whichCastMember of castLib whichCast)
Contents
script instances
vInstance = new(parentScript, arg1, arg2, ...) vInstance = script("Parent Script Name").new(arg1, arg2, ...) new(script Parent Script Name", value1, value2, ...)
timeout objects
Director 8.0 to MX
timeout("name").new(timeoutPeriod, #timeoutHandler {, targetObject})
Director 10
timeOut().new("name", timeOutPeriod, #timeOutHandler {, targetObject})
If you open an older (prior to MX 2004) Director movie into MX 2004, then the scriptExecutionStyle is set to 9, and you'll have to use the older timeout syntax. You can always set the scriptExecutionStyle to 10, and use the new syntax, but then, if you're already dealing with MIAWs or timeout objects, you will have to change the relevant code lines to conform with the MX 2004 style.
See: Syntax changes in Director MX 2004
xtra instances
new(xtra "xtraName") vInstance = xtra("xtraName").new()
member
vMember = new(#field) vMember = new("field") vMember = new(#field, member(3,1) ) -- overwrites existing member if necessary.
Bugs/Quirks/Problems
If you call for instance...
new(#bitmap)
... and have a Movie Script with a new() handler, then the handler of the script will be called. In this case you will not get a member (probably the return value will be #bitmap). So if you get this error - keep a look out if you mistakenly set a Parent Script or behavior to Movie Script in the properties dialog.