PDA

View Full Version : Whats wrong with my code?


setsolid
07-15-2005, 08:03 PM
Hello,

I was taking that tweening tutorial and got stuck on the easing part.
The errors are always in the Math.something part of the code. Once
I removed all Math aspects of the code I still had tweening but of
course no easing. I copied the code straight from the tut.

Math.square = function (n){
return n*n;
}
var currentFrame = 0;
ball_mc.onEnterFrame = function(){
ball_mc._x = 50 + Math.square(currentFrame/10) * 450;
if (++currentFrame > 10) delete this.onEnterFrame;
}

deadbeat
07-15-2005, 08:15 PM
You can't add functions to the Math object like that in AS 2...

K.

setsolid
07-15-2005, 08:59 PM
I am just looking for the simplest way to ease a tween for both buttons and movies clips.

deadbeat
07-15-2005, 09:23 PM
Just make it a regular function:

square = function (n){
return n*n;
}
var currentFrame = 0;
ball_mc.onEnterFrame = function(){
ball_mc._x = 50 + _root.square(currentFrame/10) * 450;
if (++currentFrame > 10) delete this.onEnterFrame;
}