ACtl.import
Loads a Javascript module file as a module object.
This is equivalent to Javascript's import function, but allows to import any local file or URL.
ACtl.import(location) is identical to ACtl.getFile(location, 'module'). It exists for convenience.
ACtl.import(fileLocation) fileLocation Type: string
Either a URL, data URI, local path or UNC path pointing to a Javascript module file. It can be relative to the script's location (if there is one). It can also contain placeholders such as <desktop>, <documents> and others.
Returns Type: Promise Resolves to: module object
Returns immediately. The Promise will resolve with the module object.
Throws Type: string
Error description if fileLocation cannot be accessed.
Example
Given the following Javascript module:
//C:/Projects/Teleporter/functions.js
export function teleportTo(destination){
alert('We are now in ' + destination) ;
}
We can import that module into our own scope as follows:
try{
let myModule = await ACtl.import('C:/Projects/Teleporter/functions.js') ;
//now the entire module is in the `myModule` object
myModule.teleportTo('Mars') ;
}catch( error ){
alert( "Couldn't import functions.js. The error was: " + error ) ;
}