Using the Accelerometer APIs


		
	





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"/>

 Adobe

Get help faster and easier

New user?

Adobe MAX 2024

Adobe MAX
The Creativity Conference

Oct 14–16 Miami Beach and online

Adobe MAX

The Creativity Conference

Oct 14–16 Miami Beach and online

Adobe MAX 2024

Adobe MAX
The Creativity Conference

Oct 14–16 Miami Beach and online

Adobe MAX

The Creativity Conference

Oct 14–16 Miami Beach and online