PDA

View Full Version : creating in one function, accessing from another


SirDuke
03-13-2008, 11:52 PM
i guess it's simple, but i just can't do it. I create some controls in a function (eg. a slider and a textField) and then i want to access their properties from another function.

The way to go around it is to call the 2nd function from the first and pas the objects as arguments. But that's not pretty. There has to be some other, simpler way. Right? :eek:

peter.vullings
03-14-2008, 12:13 AM
A quicker way, but not truly 'object oriented' is to define the object as a global variable outside both functions - or at least in a scope that both functions can access:

e.g:

var myTextField : TextField;

function createTF(){
myTextField = new TextField();
}
function updateTF(){
myTextField.text = 'updated';
}