Flv buffer animation

respected programmers,

i am trying to make a flv http progressive download mechanism.
the mechanism involves a preloader to show when the buffer is refilling.

My code is like this:

if(infoObject.code.toString()==‘NetStream.Buffer.Empty’)
{
my_video._alpha=30;
var ldr:MovieClip=_root.attachMovie(“loader”,“loader”,0);
ldr._x=Stage.width/2;
ldr._y=Stage.height/2;
}
if(infoObject.code.toString()==‘NetStream.Buffer.Full’)
{
my_video._alpha=100;
_root.loader.removeMovieClip();
}
if(infoObject.code.toString()==‘NetStream.Buffer.Flush’)
{
//stream_ns.seek(0);
stream_ns.play(vidName);
}


However i notice that , each time the buffer fills up, the stream starts playing before the loader is removed from screen. I want to to know, why this lag is there.

also how can i solve this problem , so that each time the buffer is full again, the loader should be removed first and then the stream should play.