Take the 2-minute tour ×

First,Sorry for my English. I wanted to make a flash game,it's about some fish swiming in a tank. All the fishes swim randomly,i don't need any rotation,just left and right direction will be fine with me. But the result is their actions are really odd. Can someone tell me how to make them swim just like real fishes?

And there's also another problem.When the number of fishes increased to 50 or more,the framerate will drop rapidly.

Sorry for my English again.

Now I use Tweenlite to control the swiming action ,and it works very well.But the framerate still drops if i add more than 40 or 50 fishes to the tank.I think there must be a better way to do this.

Here's my code

public  function onEnterFrame(event:Event):void{
        var time:Number = Math.sqrt(Math.pow(xOffset,2)+Math.pow(yOffset,2))/speed;
        TweenLite.to(this,time,{x:x+xOffset ,y:y+yOffset*0.5 ,ease:Quad.easeOut,onComplete:moveComplete});

xOffset and yOffset in the code are random numbers

share|improve this question
without any code or swfs to look at, it's impossible to answer your question. –  back2dos Jul 5 '10 at 16:04
I tried google.com/search?q=sprite+fish+flash+animation , but i got nothing –  ertao Jul 6 '10 at 2:15
Hey @ertao welcome to StackOverflow !, you want to read up on the FAQ stackoverflow.com/faq first to get a hand of how things work around here. Also you would need to be a bit more descriptive in your question and maybe add some of your source code from the Fla for us to understand how the program works. It is ok if you are not that well in English the community will edit your post to make it more readable . Do you mean an animation like this activeden.net/item/live-fish-as2as3/70693 ? –  phwd Jul 6 '10 at 2:19
sorry, this is not what i want,but thanks! –  ertao Jul 6 '10 at 2:43

1 Answer 1

Using the OEF function you will create a new Tween and Calculate new movement Each frame. Maybe you should think of a cheaper way to calculate random movement.

Another solution is to chunk of the calculations so you only do a portion of the fish at the same time. So during each frame you only calculate 1/5 of the fish.

share|improve this answer

Your Answer


