This is my as2 code:
Code: Select all
function walk(horizontal,vertical){
avatarMC._x += horizontal;
avatarMC._y += vertical;
if (inited)
{
if (!_global.isBusy)
{
var px:Number = int(avatarMC._x)
var py:Number = int(avatarMC._y)
if ((px > avatarW/2) && (px < areaW - avatarW/2) && (py > avatarH/2) && (py < areaH - avatarH/2))
{
// save new variables
// Please note that init is set to false:
// this means that we're only moving somewhere and we don't need to init tha avatar
smartfox.setUserVariables({px:px, py:py, init:false})
// method derived from the [flashAPI].as
// moves the mc using the "Quint" equation, with "InOut" easying
// to the new px,py position in 100 milliseconds.
}
}
}
}
if(Key.isDown(Key.RIGHT)){
_root.walk(5,0);
}
if(Key.isDown(Key.LEFT)){
_root.walk(-5,0);
}
myMouse.onMouseDown = function()
{
_root.walk(0,-5);
}
if(Key.isDown(Key.DOWN)){
_root.walk(0,5);
}