root/as3/OSCemote/branches/saqoosha/samples/Sample.as

リビジョン 1339, 2.1 kB (コミッタ: saqoosha, コミット時期: 3 年 前)

ええええい、こんどこそ。

Line 
1 package {
2         import uranodai.oscemote.OSCemote;
3         import uranodai.oscemote.event.OSCemoteAccelerationEvent;
4         import uranodai.oscemote.event.OSCemoteButtonEvent;
5         import uranodai.oscemote.event.OSCemoteSegmentEvent;
6         import uranodai.oscemote.event.OSCemoteSliderEvent;
7         import uranodai.oscemote.event.OSCemoteSwitchEvent;
8         import uranodai.oscemote.event.OSCemoteTouchEvent;
9
10         import flash.display.Sprite;   
11
12         [SWF(width="400",height="300",frameRate="60",backgroundColor="#FFFFFF")]
13
14         public class Sample extends Sprite {
15
16                 private var oscemote:OSCemote;
17
18                 public function Sample() {
19                         oscemote = new OSCemote();
20                         oscemote.addEventListener(OSCemoteButtonEvent.BUTTON_DOWN, this._onButtonDown);
21                         oscemote.addEventListener(OSCemoteButtonEvent.BUTTON_UP, this._onButtonUp);
22                         oscemote.addEventListener(OSCemoteSliderEvent.SLIDER_CHANGE, this._onSliderChange);
23                         oscemote.addEventListener(OSCemoteSegmentEvent.SEGMENT_CHANGE, this._onSegmentChange);
24                         oscemote.addEventListener(OSCemoteSwitchEvent.STATE_CHANGE, this._onSwitchStateChange);
25                         oscemote.addEventListener(OSCemoteTouchEvent.TOUCH, this._onTouch);
26                         oscemote.addEventListener(OSCemoteAccelerationEvent.ACCELERATION_CHANGE, this._onAccelChange);
27                         oscemote.connect();
28                 }
29
30                 public function _onButtonDown(e:OSCemoteButtonEvent):void {
31                         trace('_onButtonDown', e.button);
32                 }
33
34                 public function _onButtonUp(e:OSCemoteButtonEvent):void {
35                         trace('_onButtonUp', e.button);
36                 }
37
38                 public function _onSliderChange(e:OSCemoteSliderEvent):void {
39                         trace('_onSliderChange', e.index, e.value);
40                 }
41
42                 public function _onSegmentChange(e:OSCemoteSegmentEvent):void {
43                         trace('_onSegmentedChange', e.value);
44                 }
45
46                 public function _onSwitchStateChange(e:OSCemoteSwitchEvent):void {
47                         trace('_onSwitchStateChange', e.index, e.state);
48                 }
49
50                 public function _onTouch(e:OSCemoteTouchEvent):void {
51                         trace('_onTouch', e.count);
52                         for (var i:int = 0; i < e.count; i++) {
53                                 trace('---', i, e.getPosition(i));
54                         }
55                 }
56
57                 public function _onAccelChange(e:OSCemoteAccelerationEvent):void {
58                         trace('_onAccelChange', [e.x, e.y, e.z]);
59                 }
60         }
61 }
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。