home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
404 Jogos
/
CLJG.iso
/
Puzzle
/
Easter_Eggs.swf
/
scripts
/
__Packages
/
com
/
novelgames
/
flashgames
/
eggsAS2
/
Egg.as
< prev
next >
Wrap
Text File
|
2008-09-04
|
5KB
|
138 lines
class com.novelgames.flashgames.eggsAS2.Egg extends com.novelgames.flashgames.commonAS2.NewMovieClip
{
function Egg()
{
super();
this.button.__proto__ = com.novelgames.flashgames.commonAS2.NewButton.prototype;
this.picture.__proto__ = com.novelgames.flashgames.commonAS2.NewMovieClip.prototype;
}
function initialize(x, y, type)
{
this.__set__x(x);
this.__set__y(y);
this.type = type;
this.picture.gotoAndStop(type + 1);
this.showNormal();
this.cacheAsBitmap = true;
this.button.addEventListener(com.novelgames.flashgames.commonAS2.MouseEvent.CLICK,this,"buttonClicked");
}
function setXY(x, y)
{
this.indexX = x;
this.indexY = y;
}
function showNormal()
{
this.button.__set__visible(true);
this.gotoAndStop("normal");
}
function showChosen()
{
this.button.__set__visible(false);
this.gotoAndStop("chosen");
}
function swapTo(x, y)
{
this.targetX = x;
this.targetY = y;
this.targetRealX = Object(this.__get__parent().parent).getRealX(x,y);
this.targetRealY = Object(this.__get__parent().parent).getRealY(x,y);
this.speedX = (this.targetRealX - this.__get__x()) * 1000 / com.novelgames.flashgames.eggsAS2.Config.SWAPTIME;
this.speedY = (this.targetRealY - this.__get__y()) * 1000 / com.novelgames.flashgames.eggsAS2.Config.SWAPTIME;
this.isSwapping = true;
this.startTime = com.novelgames.flashgames.commonAS2.NewTimer.getTimer();
this.endTime = this.startTime + com.novelgames.flashgames.eggsAS2.Config.SWAPTIME;
this.lastTime = this.startTime;
}
function unswapTo(x, y)
{
this.targetX = x;
this.targetY = y;
this.targetRealX = Object(this.__get__parent().parent).getRealX(x,y);
this.targetRealY = Object(this.__get__parent().parent).getRealY(x,y);
this.speedX = (this.targetRealX - this.__get__x()) * 1000 / com.novelgames.flashgames.eggsAS2.Config.SWAPTIME;
this.speedY = (this.targetRealY - this.__get__y()) * 1000 / com.novelgames.flashgames.eggsAS2.Config.SWAPTIME;
this.isUnswapping = true;
this.startTime = com.novelgames.flashgames.commonAS2.NewTimer.getTimer();
this.endTime = this.startTime + com.novelgames.flashgames.eggsAS2.Config.SWAPTIME;
this.lastTime = this.startTime;
}
function destroy()
{
this.isDestroying = true;
this.startTime = com.novelgames.flashgames.commonAS2.NewTimer.getTimer();
}
function drop(y)
{
this.targetX = this.indexX;
this.targetY = y;
this.targetRealX = this.x;
this.targetRealY = Object(this.__get__parent().parent).getRealY(this.indexX,y);
this.speedX = 0;
this.speedY = com.novelgames.flashgames.eggsAS2.Config.DROPSPEED;
this.isDropping = true;
this.startTime = com.novelgames.flashgames.commonAS2.NewTimer.getTimer();
this.endTime = this.startTime + Math.floor((this.targetRealY - this.__get__y()) * 1000 / com.novelgames.flashgames.eggsAS2.Config.DROPSPEED);
this.lastTime = this.startTime;
}
function onTime()
{
var _loc2_ = com.novelgames.flashgames.commonAS2.NewTimer.getTimer();
this.move(_loc2_);
this.lastTime = _loc2_;
}
function move(time)
{
var _loc2_ = undefined;
if(!Object(this.__get__parent().parent).gameStarted)
{
return undefined;
}
if(this.isSwapping || this.isUnswapping || this.isDropping)
{
this.x += this.speedX * (time - this.lastTime) / 1000;
this.y += this.speedY * (time - this.lastTime) / 1000;
if(time >= this.endTime)
{
this.__set__x(this.targetRealX);
this.__set__y(this.targetRealY);
if(this.isSwapping)
{
this.isSwapping = false;
Object(this.__get__parent().parent).finishSwapping();
}
else if(this.isUnswapping)
{
this.isUnswapping = false;
Object(this.__get__parent().parent).finishUnswapping();
}
else if(this.isDropping)
{
this.isDropping = false;
Object(this.__get__parent().parent).finishDropping();
}
}
}
else if(this.isDestroying)
{
_loc2_ = (time - this.startTime) / com.novelgames.flashgames.eggsAS2.Config.DESTROYTIME;
if(_loc2_ > 1)
{
_loc2_ = 1;
}
this.__set__scaleX(1 - _loc2_);
this.__set__scaleY(1 - _loc2_);
if(_loc2_ >= 1)
{
this.__set__visible(false);
this.isDestroying = false;
Object(this.__get__parent().parent).finishDestroying();
}
}
}
function buttonClicked(mouseEvent)
{
Object(this.__get__parent().parent).chooseEgg(this);
}
}