column

2013-01-04|Flash-if文

CATEGORY ActionScript Adobe Flash PC & Web お勉強 TAG, ,

投稿日:2013年4月30日 更新日:

執筆者:

2013-01-04

Flash-if文

  • if文

    • 比較演算子

 

Gadgets powered by Google


function文


onClipEvent (load) {
var speed = 10;
var leftEdge = -20;
var rightEdge = 520;
}
onClipEvent (enterFrame) {
this._x += speed;
if (this._x >= rightEdge){
this._x = leftEdge;
}
}

var speed:Number;
var rightEdge:Number;
var leftEdge:Number;
this.onLoad = function() {
	speed = 10;
	leftEdge = -20;
	rightEdge = 520;
}
ball_mc.onEnterFrame = function() {
	ball_mc._x += speed;
	if(ball_mc._x >= rightEdge) {
		ball_mc._x = leftEdge;
	}
}
  • y軸もプラスする


Gadgets powered by Google

  • 最初に書いたScript

onClipEvent (load) {
	var speedx : Number = 8;
	var speedy : Number = 10;
	var rightEdge : Number = 450;
	var leftEdge : Number = 50;
	var topEdge : Number = 50;
	var bottomEdge : Number = 350;
}
onClipEvent (enterFrame) {
	if(_x > rightEdge) {
		speedx *= -1;
	}
	if(_x < leftEdge) {
		speedx *= -1;
	}
	if(_y > topEdge) {
		speedy *= -1;
	}
	if(_y < bottomEdge) {
		speedy *= -1;
	}
		_x += speedx;
		_y += speedy;
}

onClipEvent (load) {
	var speedX : Number = 9;
	var speedY : Number = 10;
	var rightEdge : Number = 500;
	var leftEdge : Number = 0;
	var topEdge : Number = 0;
	var bottomEdge : Number = 400;
}
onClipEvent (enterFrame) {
	if(_x > rightEdge - _width/2 || _x < leftEdge + _width/2) {
		speedX *= -1;
	}
		_x += speedX;

	if(_y < topEdge + _height/2  || _y > bottomEdge - _height/2) {
		speedY *= -1;
	}
		_y += speedY;
}

	var speedX : Number = 9;
	var speedY : Number = 10;
	var rightEdge : Number = 500;
	var leftEdge : Number = 0;
	var topEdge : Number = 0;
	var bottomEdge : Number = 400;
this.onEnterFrame = function() {
	if(beer_mc._x > rightEdge - beer_mc._width/2 || beer_mc._x < leftEdge + beer_mc._width/2) {
		speedX *= -1;
	}
		beer_mc._x += speedX;

	if(beer_mc._y < topEdge + beer_mc._height/2  || beer_mc._y > bottomEdge - beer_mc._height/2) {
		speedY *= -1;
	}
		beer_mc._y += speedY;
}

コメントを残す

関連記事

PREV

2012-12-27|JavaScript-画像置換

NEXT

2013-01-05|JavaScript〜if文〜function

2013-01-04|Flash-if文

side bar

メニューはこちら

メニューはこちら