Square Transition

Hi guys,
Im new here and fairly new to action scripting.

Just wondering if anyone can help me write a script with this kind of transition or explain how you would create it.

It actually looks fine in the attachment but when i add a new layer with a key frame the animation freeze’s and just flickers

Please help!!!

Thanks in advanced

Gen