AS11(再)

  • オブジェクトアクション
onClipEvent (load) {
	var speed:Number = 5;
	var left:Number = 0;
	var right:Number = 550;
}
onClipEvent (enterFrame) {
	if (this._x > right - this._width / 2 || this._x  < left + this._width / 2)
	{
		speed*= -1;
		this._xscale *= -1;
	}
	this._x += speed;
}
onLoad = function()  {
	var speed:Number = 5;
	var left:Number = 0;
	var right:Number = 550;
}
onEnterFrame = function() {
	if (tai_mc._x > right - tai_mc._width / 2 || tai_mc._x  < left + tai_mc._width / 2)
	{
		speed*= -1;
		tai_mc._xscale *= -1;
	}
	tai_mc._x += speed;
}
  • ユーザー定義関数
	var speed:Number = 5;
	var left:Number = 0;
	var right:Number = 550;

function xMove()
{
	tai_mc.onEnterFrame = function()
	 {
	if (tai_mc._x > right - tai_mc._width / 2 || tai_mc._x  < left + tai_mc._width / 2)
	{
		speed*= -1;
		tai_mc._xscale *= -1;
	}
	tai_mc._x += speed;
       }
}

  • オブジェクトアクション
onClipEvent (load) {
	var speedX:Number = 5;
	var speedY:Number = 5;
	var left:Number = 0;
	var right:Number = 550;
	var top:Number = 0;
	var bottom:Number = 400;
}
onClipEvent (enterFrame) {
	if (this._x > right - this._width / 2 || this._x  < left + this._width / 2)
	{
		speedX *= -1;
		this._xscale *= -1;
	}
	this._x += speedX;

	if (this._y > bottom - this._height / 2 || this._y < top + this._height / 2)
	{
		speedY *= -1;
	}
	this._y += speedY;
}
onLoad = function() {
	var speedX:Number = 5;
	var speedY:Number = 5;
	var left:Number = 0;
	var right:Number = 550;
	var top:Number = 0;
	var bottom:Number = 400;
}
onEnterFrame = function() {
	if (tai_mc._x > right - tai_mc._width / 2 || tai_mc._x  < left + tai_mc._width / 2)
	{
		speedX *= -1;
		tai_mc._xscale *= -1;
	}
	tai_mc._x += speedX;

	if (tai_mc._y > bottom - tai_mc._height / 2 || tai_mc._y < top + tai_mc._height / 2)
	{
		speedY *= -1;
	}
	tai_mc._y += speedY;
}
  • ユーザー定義関数
var speedX:Number = 5;
var speedY:Number = 5;
var left:Number = 0;
var right:Number = 550;
var top:Number = 0;
var bottom:Number = 400;

function xMove()
{
	tai_mc.onEnterFrame = function()
	{
		if (tai_mc._x > right - tai_mc._width / 2 || tai_mc._x < left + tai_mc._width / 2)
		{
			speedX *= -1;
			tai_mc._xscale *= -1;
		}
		tai_mc._x += speedX;
	}
}
function yMove()
{
	tai_mc.onEnterFrame = function()
	{
		if (tai_mc._y > bottom - tai_mc._height / 2 || tai_mc._y < top + tai_mc._height / 2)
		{
			speedY *= -1;
		}
		tai_mc._y += speedY;
	}
}