AS Functions Variables
- Started
- Last post
- 10 Responses
- qaddisin
Is there a way to access a textfield created in a function outside the that function in another function. I can do a work around easily -- just wondering if there is something i missed, something easier to use. cheers
- imakedesign0
just dont define the textfield variable in the function. i.e dont use var within your function.
- qaddisin0
ah yes that would be an easy response, in this case i am geting and defining textfield settings from data loaded dynamically and i can have the textfield defined before that data is loaded.
my workaround is to setup textfields with 0,0,0,0 and then redefine the textfields x,y,width and height. but of course this is an extra step
if there was a way to define a textfield and then access that textfield somewhat like
this.functionName.textField that would kewl or something like that.
thanks tho.
- Solid0
Can you post your code?
http://pastebin.coconut.se/
- qaddisin0
Pasted Code:
http://pastebin.coconut.se/?id=4…tried to simplify it a little. may have left some info out. but heres whats going on:
1. using mc tween prototypes
2. created hideText prototype
3. initial variable: rootLevel
4. loadData, runs showContent
5. showContent cretaes TF
6. asfunction calls getPage
[not shown]7. hide TF and then reveals TF
Problem: can't access the TF in order to changes its text string. like the pastecode bin idea. cheers.
- Solid0
In your showContent() function:
-----
i
- unfittoprint0
your function should return a textfield instead of nothing [Void].
- Solid0
damn - what happened to my post?
- Solid0
unfit is right - that would be the easiest fix (depending on the sequence of events).
- unfittoprint0
and using protoypes when exporting AS2.0 is not advisable.
Make a new class instead.
Remember: some of the build-in classes like Math, Textfield cannot be extended. Try something like Textfield2 ou Math2...
- qaddisin0
ok i'll try something like that [returning a textfield], will this work for an array?.
i am not a ood master as of yet, so i tweaked some prototypes laying around. but i am getting into creating my own classes at a later time. thanks for the point in the right directions.
peace to all.