Well guys, i have a problem when moving sprites. I manage to make the sprites move and get back to their position after i release the key. But when i stay with the key pressed, the image of the sprites moves, but the animation doesn’t seem like it’s walking. It’s stays frozen.
This is my code:
All the “hero#” are MC
onClipEvent(load)
{
step=5;
movieWidth=300;
movieHeight=300;
movieheight1=0;
this.stop();
}
onClipEvent(enterFrame)
{
if (Key.isDown (Key.RIGHT) && this._x < movieWidth)
{
this.attachMovie("hero1", "hero2", 10);
this._x+=step;
}
if (Key.isDown (Key.LEFT) && this._x > 0)
{
this.attachMovie("hero3", "hero4", 10 );
this._x+=-step;
}
if (Key.isDown (Key.DOWN) && this._y < movieHeight)
{
this.attachMovie("hero5", "hero6", 10 );
this._y+=step;
}
if (Key.isDown (Key.UP) && this._y > 0)
{
this.attachMovie("hero7", "hero7", 10 );
this._y+=-step;
}
}
This is the SWF so you can judge it by yourself:
http://www.petaimg.com/u211/187123qw.swf