Dynamicly Optimize a Shape

Hello,
I was wondering if there is a way through AS that one could preform the same effect as if they had gone: MODIFY>>SHAPE>>OPTIMIZE SHAPE

does anyone know how I can smooth out my lines like that?
Thanks!