Mixing the graphics with the game logic is usually a very bad idea. You want to separate them, to allow both to live in their own world, so in case you want to change an animation name or a variable name it doesn't mess up your whole project.
Don't focus on how to achieve this particular task, what is your overall objective ? Why do you need to bind variables to animations ? What are you trying to achieve?