Before you begin, see Accelerometer Functions.

Setting Accelerometer options

<cfclient>

<cfset res = cfclient.accelerometer.getOptions()>
<cfset res.frequency=20000>
<cfset cfclient.accelerometer.setOptions(res)>
 
</cfclient>

Watching Accelerometer changes

<cfclientsettings enableDeviceAPI=true>
<cfclient>
 
<cfset opt=cfclient.accelerometer.getOptions()>
<!--- Assuming a <div> element is defined with id "result"--->
<cfset document.getElementById('result').innerHTML="Options object: #JSON.stringify(opt)#">
<cfset watchId=cfclient.accelerometer.watch("callbackfunc",opt)>
<cfset document.getElementById('result').innerHTML=document.getElementById('result').innerHTML+"Watch Id: #watchId#"> 
 
<cffunction access="public" name="callbackfunc" returntype="void" >
<cfargument name="acceleration">
<cfset document.getElementById('result').innerHTML=document.getElementById('result').innerHTML+"<br>Value from callback function"> 
</cffunction>

</cfclient>
 
<div id="result"/>

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy