קבלו שיפור( הפכתי את זה לפונקציה)
PHP קוד:
function buttony(theName, endFrame){
y1 = this[theName]._y;
y2 = this[theName]._height + y1;
x1 = this[theName]._x;
x2 = this[theName]._width + x1;
if((_ymouse > y1 && _xmouse > x1) && (_ymouse <= y2 && _xmouse <= x2)){
if( this[theName].getCurrentFrame == undefined) this[theName].getCurrentFrame = 2;
if( this[theName].getCurrentFrame < endFrame){
this[theName].getCurrentFrame++;
this[theName].gotoAndPlay(this[theName].getCurrentFrame);
}
}
else
{
if( this[theName].getCurrentFrame !== undefined){
if( this[theName].getCurrentFrame > 0){
this[theName].getCurrentFrame--;
this[theName].gotoAndPlay(this[theName].getCurrentFrame);
}
}
}
}
myBott.onEnterFrame = function(){
buttony( "myBott" ,30);
}