Can i assign vars to an object on the fly?

more specifically: if i have an input box on the stage, can i assign it a variable via an event (let’s say a button click)?

something like:

button1.onPress=function(){
myInputBox.var = variable1;
}
button2.onPress=function(){
myInputBox.var = variable2;
}

PS i know the .var doesn’t exist btw (-: - it depits what i’m trying to achieve