匿名関数-スロット
イベントハンドラ
onRelease
オブジェクトがクリックされたとき〜する
onRollOver
オブジェクトの上にポインタが乗った状態のとき〜する
onKeyDown
あるキーが押されたとき〜する
ムービークリップのイベントハンドラメソッド
イベント | 説明 |
---|---|
onLoad | onClipEvent ( load ) ハンドラのイベントハンドラメソッド版 |
onUnload | onClipEvent ( unLoad ) ハンドラのイベントハンドラメソッド版 |
onEnterFrame | onClipEvent ( enterFrame ) ハンドラのイベントハンドラメソッド版 |
onMouseDown | onClipEvent ( mouseDown ) ハンドラのイベントハンドラメソッド版 |
onMouseUp | onClipEvent ( mouseUp ) ハンドラのイベントハンドラメソッド版 |
onMouseMove | onClipEvent ( mouseMove ) ハンドラのイベントハンドラメソッド版 |
onKeyDown | onClipEvent ( keyDown ) ハンドラのイベントハンドラメソッド版 |
onKeyUp | onClipEvent ( keyUp ) ハンドラのイベントハンドラメソッド版 |
onData | onClipEvent ( data ) ハンドラのイベントハンドラメソッド版 |
ボタンのイベントハンドラメソッド
onPress | on ( press ) ハンドラのイベントハンドラメソッド版 |
---|---|
onRelease | on ( release ) ハンドラのイベントハンドラメソッド版 |
onReleaseOutside | on ( releaseOutside ) ハンドラのイベントハンドラメソッド版 |
onRollOut | on ( rollOut ) ハンドラのイベントハンドラメソッド版 |
onRollOver | on ( rollOver ) ハンドラのイベントハンドラメソッド版 |
onDragOut | on ( dragOut ) ハンドラのイベントハンドラメソッド版 |
onDragOver | on ( dragOver ) ハンドラのイベントハンドラメソッド版 |
onKillFocus | インスタンスがフォーカスを失った。 |
onSetFocus | インスタンスがフォーカスを受け取った。 |
イベントハンドラメソッド
- 関数名がないことから関数式で定義した関数
ActionScriptでは
data.onLoad = function() { /*データが読み込まれたときの処理*/ }
JavaScriptでは
window.onload = function() { /*画面が読み込まれたときの処理*/ }
《例》
描画
ボタン
- Flashの描画機能を使う(ビットマップ)
- Illustratorからコンバートする(各パーツをすべて描いてから「ボタンシンボル内」にコピー&ペースト)
- スタートボタンを複製してストップボタンをつくる(着色では色が濁るので、別の色を選択します)
- リスタートボタンも作る
カウンター
- タイムライン上に配置
Actionを記述
- Flashムービーは、停止させなければ自動再生する(まず止める)
- スタートボタンが押されたら、各カウンターが動く
- ストップボタンが押されたら、対応するカウンターが停止する
- リセットボタンでカウンターを「0」に戻す
《最も単純な記述》
onLoad = function() { num01_mc.stop(); num02_mc.stop(); num03_mc.stop(); } start_btn.onPress = function() { num01_mc.play(); num02_mc.play(); num03_mc.play(); } stop01_btn.onPress = function() { num01_mc.stop(); } stop02_btn.onPress = function() { num02_mc.stop(); } stop03_btn.onPress = function() { num03_mc.stop(); } reset_btn.onRelease = function() { num01_mc.gotoAndStop(1); num02_mc.gotoAndStop(1); num03_mc.gotoAndStop(1); }
《_rootで記述》
this.onLoad = function() { this.num01_mc.stop(); this.num02_mc.stop(); this.num03_mc.stop(); } this.start_btn.onPress = function() { _root.num01_mc.play(); _root.num02_mc.play(); _root.num03_mc.play(); } this.stop01_btn.onPress = function() { _root.num01_mc.stop(); } this.stop02_btn.onPress = function() { _root.num02_mc.stop(); } this.stop03_btn.onPress = function() { _root.num03_mc.stop(); } this.reset_btn.onRelease = function() { _root.num01_mc.gotoAndStop(1); _root.num02_mc.gotoAndStop(1); _root.num03_mc.gotoAndStop(1); }
《_parentで記述》
this.onLoad = function() { this.num01_mc.stop(); this.num02_mc.stop(); this.num03_mc.stop(); } this.start_btn.onPress = function() { this._parent.num01_mc.play(); this._parent.num02_mc.play(); this._parent.num03_mc.play(); } this.stop01_btn.onPress = function() { this._parent.num01_mc.stop(); } this.stop02_btn.onPress = function() { this._parent.num02_mc.stop(); } this.stop03_btn.onPress = function() { this._parent.num03_mc.stop(); } this.reset_btn.onRelease = function() { this._parent.num01_mc.gotoAndStop(1); this._parent.num02_mc.gotoAndStop(1); this._parent.num03_mc.gotoAndStop(1); }
《ユーザー定義関数で記述》
this.onLoad = function() { this.num01_mc.stop(); this.num02_mc.stop(); this.num03_mc.stop(); } function toPlay():Void { this._parent.num01_mc.play(); this._parent.num02_mc.play(); this._parent.num03_mc.play(); } function toStop1():Void { this._parent.num01_mc.stop(); } function toStop2():Void { this._parent.num02_mc.stop(); } function toStop3():Void { this._parent.num03_mc.stop(); } function toReset():Void { this._parent.num01_mc.gotoAndStop(1); this._parent.num02_mc.gotoAndStop(1); this._parent.num03_mc.gotoAndStop(1); } this.start_btn.onPress = toPlay; this.stop01_btn.onPress = toStop1; this.stop02_btn.onPress = toStop2; this.stop03_btn.onPress = toStop3; this.reset_btn.onRelease = toReset;