How to write a script for fly out menus (Parent - Child - Sub Child)

How to write a script for fly out menus (Parent - Child - Sub Child)