The CreateObject function can create a ColdFusion component (CFC) object.
CreateObject(type, component-name)
| Parameter | Description |
|---|---|
| type |
Type of object to create.
|
| component-name |
name of a component method |
In the following example, the CFScript statements assign the tellTimeCFC variable to the tellTime component using the createObject function. The createObject function references the component in another directory. To invoke component methods, you use function syntax. For more information, see Developing ColdFusion MX Applications with CFML.
<b>Server's Local Time:</b>
<cfscript>
tellTimeCFC=createObject("component","appResources.components.
tellTime");
tellTimeCFC.getLocalTime();
</cfscript>
<br>
<b>Calculated UTC Time:</b>
<cfscript>
tellTimeCFC.getUTCTime();
</cfscript>