copied source from as3isolib