Hi all.
I’ve created a game/website section (www.iso-land.com click interactive site to see it), i have a strange easing problem which i cant work out. I’ve created a character that should ease to each square instead of just jumping to the next square.
When i test the movie inside flash, the easing works fine, but when i then test the same movie again using flash player or test the uploaded file the character just jumps to the next square. Here’s the script i used, can anyone work out why its doing this?
currentroom = 'bedroom';
//For each file, change this variable to
//whatever the current room is.
//Also, only use letters, no spaces or puncutation
//And, keep it as short and simple as possible.
desk2._visible = false;
interactive._visible = false;
tv._visible = false;
bed2._visible = false;
locked._visible = false;
_global.stepAction = function(steppedOn) {
isOnAnItem = false;
if (steppedOn == 0) {
tv._visible = false;
interactive._visible = false;
bed1._visible = true;
bed2._visible = false;
desk1._visible = true;
desk2._visible = false;
locked._visible = false;
} else if (steppedOn == 2) {
clearInterval(moverID);
_level0.gotoAndPlay("Hallway");
} else if (steppedOn == 3) {
trace('object');
isOnAnItem = true;
} else if (steppedOn == 6) {
interactive._visible = true;
} else if (steppedOn == 7) {
tv._visible = true;
} else if (steppedOn == 4) {
bed2._visible = true;
bed1._visible = false;
desk2._visible = true;
desk1._visible = false;
} else if (steppedOn == 5) {
locked._visible = true;
}
_global.stepped_on = steppedOn;
};
_global.itemAction = function(item) {
if ((stepped_on == 5) && (item == 'key')) {
clearInterval(moverID);
locked._visible = false;
} else {
return false;
}
return true;
};
// first set up spacing and collisions
spacing = 20;
movingTo = null;
collisions = [
[1, 1, 1, 1, 1, 1, 1, 4, 4, 0, 0, 7, 0, 0, 1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1, 1, 4, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1],
[0, 6, 0, 0, 0, 0, 0, 4, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 1, 1],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 1, 1],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1],
[1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
];
if(!_global[currentroom]){
for (xc=0; xc<collisions.length; xc++) {
for (yc=0; yc<collisions[xc].length; yc++) {
var cspace = collisions[xc][yc];
if (cspace == 3) {
ritem = _level0['item_'+xc+'_'+yc+'_'+currentroom];
ritem._alpha = 0;
ritem.enabled = false;
}
}
}
}
// set up a function to move the ball to a new grid x,y
// then set the new x, y to the ball's x, y variables
moveToGridSpace = function (x1, y1) {
movingTo = {x:spacing*(x1+y1), y:spacing/2*(x1-y1), xs:x1, ys:y1};
ball.x = x1;
ball.y = y1;
};
_global.moverID = setInterval(moveBall, 1, ball);
function moveBall(someBall) {
if (movingTo != null) {
cmoveTo = movingTo;
moveOnce(ball, cmoveTo);
}
}
function moveOnce(someBall, ballProps) {
x1 = ballProps.x;
y1 = ballProps.y;
x = x1-someBall._x;
y = y1-someBall._y;
angle = Math.atan(y/x)/(Math.PI/180);
if (x<0) {
angle += 180;
}
if (x>=0 && y<0) {
angle += 360;
}
degs = angle;
rads = degs/180*Math.PI;
step = 2;
isoSin = Math.sin(rads);
isoCos = Math.cos(rads);
stepY = isoSin*step;
stepX = isoCos*step;
someBall._x += stepX*step;
someBall._y += stepY*step;
if (Math.abs(x)<Math.abs(isoCos*step) && Math.abs(y)<Math.abs(isoSin*step) || someBall._x == x1 && someBall._y == y1) {
someBall._x = x1;
someBall._y = y1;
movingTo = null;
stepAction(collisions[ballProps.xs][ballProps.ys]);
}
updateAfterEvent();
}
// set up a function to get the ball's grid x,y based on its position
// then assign the new values to the ball's x, y variables
SetGridSpace = function () {
ball.x = Math.round((ball._x/spacing+2*ball._y/spacing)/2);
ball.y = Math.round((ball._x/spacing-2*ball._y/spacing)/2);
};
// set a function to determine if the grid space x, y is a valid
// space for movement returning true if valid, false if not
IsValidTile = function (x, y) {
if ((collisions[x][y] !== 1) && (collisions[x][y] != undefined)) {
return true;
} else {
return false;
}
};
// set the ball to recognize key presses and move based on them
Key.addListener(ball);
released = new Boolean(true);
ball.onKeyDown = function() {
if (movingTo != null) {
return;
}
if (released) {
released = true;
var xmove, ymove;
if (Key.isDown(Key.UP)) {
ball.gotoAndStop('up');
ymove = 1;
} else if (Key.isDown(Key.DOWN)) {
ball.gotoAndStop('down');
ymove = -1;
} else if (Key.isDown(Key.LEFT)) {
ball.gotoAndStop('left');
xmove = -1;
} else if (Key.isDown(Key.RIGHT)) {
ball.gotoAndStop('right');
xmove = 1;
} else if (Key.isDown(Key.SPACE) && isOnAnItem) {
citem1 = this._parent['item_'+this.x+'_'+this.y+'_'+currentroom];
citem2 = _level0['item_'+this.x+'_'+this.y+'_'+currentroom];
citem1._visible = false;
citem2._alpha = 100;
citem2.enabled = true;
inventory.push(citem2);
trace('You are currently holding the following items:');
trace(inventory);
collisions[this.x][this.y] = 0;
}
// update new position based on ball's current
xmove += this.x;
ymove += this.y;
if (IsValidTile(xmove, ymove)) {
moveToGridSpace(xmove, ymove);
}
}
};
ball.onKeyUp = function() {
released = true;
};
SetGridSpace();
_global[currentroom] = true;
Thanks