View Full Version : dynamic text field question
what's the difference between the text field's instance name and var?
Persian-Rice
08-01-2003, 04:14 PM
one isnt a variable................
i think :)
which one allows access to a text fields properties and methods? and what does the other one do then?
Sualdam
08-01-2003, 04:20 PM
The instance name allows you to treat the textfield as an object.
The variable name just holds the value/contents of the textfield.
So, using the variable name:fieldname = "This will be displayed";but with the instance name:instancename.text = "This will be displayed";The .text property is just one of MANY properties that make textfields far more powerful when treated as objects.
so 'var' is the exact same thing as 'theinstancename.text'? that seems silly, other than for not having to type so much.
Sualdam
08-01-2003, 04:30 PM
Silly?
Well, see if you can answer these: How would you -
1. Change the textfield type on-the-fly
2. Change the background colour on-the-fly
3. Change the textfield width on-the-fly
if you only had the variable name?
If you treat the textfield as an object you use:txtName.type = "input";
txtName.backgroundColor = myColor; //In hex
txtName.textWidth = 200; //In pixelsThere are over two dozen properties that make textfields hugely more powerful when treated as objects. It also means you can create textfields using code rather than designing them in.
yeah, ok, i understand all that: with an instance name, one can access their properties and methods.
now all i'm asking is that the only purpose of the 'var' field is act just like 'instancename.text'?
Sualdam
08-01-2003, 04:41 PM
Basically, yes.
I would guess that in future versions of Flash it (the var name) will disappear from the Property Inspector. However, all Flash 5 actions are still compatible with MX.
gotcha. that makes so much sense now. i never understood the purpose of 'var'.
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.