トップへ戻るニュースフォーラムFLASH-ML 過去ログBak@Flaダウンロードよくある質問と答
ログイン
ユーザ名:

パスワード:


パスワード紛失

新規登録
メインメニュー
メイン
   コーダーズルーム【スクリプト系】
     onEnterFrameの動作
投稿するにはまず登録を

フラット表示 前のトピック | 次のトピック
投稿者 スレッド
Fumio
Åê¹ÆNo.25791
投稿日時: 2006-5-28 20:02
ちょんまげら
居住地: 東京
投稿: 4531
使用環境:
Re: onEnterFrameの動作
[デバッグ] > [変数のリストアップ]で、変数の設定タイムラインと、その意味を理解される必要があると思われます。
引用:
Duke15さんは書きました:
この関係で更に以下のコードを試しました。

[変数のリストアップ]より引用:
ムービークリップ: ターゲット="_level0.ball1_mc"
変数 _level0.ball1_mc.speed = 10
変数 _level0.ball1_mc.accel = 1
変数 _level0.ball1_mc.boundPos = 200
ムービークリップ: ターゲット="_level0.ball2_mc"
変数 _level0.ball2_mc.speed = 10
変数 _level0.ball2_mc.accel = 1
変数 _level0.ball2_mc.boundPos = 200

引用:
//MovieClip:ball1_mc,ball2_mc
onClipEvent (load) {
    speed = 0;
    accel = 1;
    boundPos = 200;
}
onClipEvent (enterFrame) {
    this._y += speed;
    if (this._y >= boundPos) {
        speed *= -1;
    } else {
        speed += accel;
    }
}

すると、ちゃんと同時動作します。

[変数のリストアップ]より引用:
変数 _level0.speed = -1
変数 _level0.accel = 1
変数 _level0.boundPos = 200

引用:
しかし、以下のコードのように、
_rootの1フレに記述した場合では同時動作になりません。
...[中略]...
var speed = 0;
var accel = 1;
var boundPos = 200;
function bound () {
    this._y += speed;
    if (this._y >= boundPos) {
        speed *= -1;
    } else {
        speed += accel;
    }
}

ball1_mc.onEnterFrame = bound;
ball2_mc.onEnterFrame = bound;

タイムラインに記述したフレームアクションでも、同じ処理が行われれば、同じ動作になります。
var speed = 0;
var accel = 1;
var boundPos = 200;
function bound() {
	this._y += this.speed;
	if (this._y>=this.boundPos) {
		this.speed *= -1;
	} else {
		this.speed += this.accel;
	}
}
function xSetAnimation(_mc) {
	_mc.speed = speed;
	_mc.accel = accel;
	_mc.boundPos = boundPos;
	_mc.onEnterFrame = bound;
}
xSetAnimation(ball1_mc);
xSetAnimation(ball2_mc);


----------------
 

フラット表示 前のトピック | 次のトピック

題名 投稿者 日時
   onEnterFrameの動作 rindo 2006-5-26 17:42
     Re: onEnterFrameの動作 mayor 2006-5-26 18:20
       Re: onEnterFrameの動作 rindo 2006-5-26 19:06
         Re: onEnterFrameの動作 mayor 2006-5-26 19:17
           Re: onEnterFrameの動作 rindo 2006-5-26 23:47
     Re: onEnterFrameの動作 youich 2006-5-27 1:04
       Re: onEnterFrameの動作 rindo 2006-5-27 10:00
         Re: onEnterFrameの動作 rindo 2006-5-28 18:56
           Re: onEnterFrameの動作 mayor 2006-5-28 19:41
             Re: onEnterFrameの動作 rindo 2006-5-28 20:32
               Re: onEnterFrameの動作 Fumio 2006-5-28 20:46
                 Re: onEnterFrameの動作 rindo 2006-5-28 21:12
                 Re: onEnterFrameの動作 rindo 2006-5-28 21:16
                   Re: onEnterFrameの動作 rindo 2006-5-31 11:10
                     Re: onEnterFrameの動作 Fumio 2006-6-1 11:59
                       Re: onEnterFrameの動作 rindo 2006-6-1 18:38
         » Re: onEnterFrameの動作 Fumio 2006-5-28 20:02

投稿するにはまず登録を
 
Copyright (C) 2003 FLASH-japan. All rights reserved.
Powered by Xoops