Mix the sugar, flour and cocoa in a bowl. Add the egg yolks to the milk and whip. Add to the sugar mixutre and beat with an electric mixer.
In a skillet, melt the butter and cook the filling over medium heat until thick and can easily part while stirring. Take off the heat and add the vanilla.