加速度計 API の使用

警告 :

すべてのモバイル機能とモバイル関連機能は ColdFusion(2025リリース)で削除されました。

詳しくは、ColdFusion の非推奨の機能を参照してください。


		
	





開始する前に、加速度計機能を参照してください。

加速度計オプションの設定

<cfclient>

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

加速度計の変更の監視

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

</cfclient>
 
<div id=&quot;result&quot;/>

ヘルプをすばやく簡単に入手

新規ユーザーの場合