Building Blocks script functions help

I am trying to build building blocks of script that has functions and variables. That can be connected and disconnect from the blocks. Just from coding and not from .fla. I am not sure what is called. Something like visual script editor embedded. Any idea where to start?