-
1. Re: TextField text changed during parent's container gets reset
Ned Murphy Aug 6, 2012 10:30 AM (in response to xTLS)I won't pretend to follow all of what you just described, but here's an observation... In the function you show you are assigning "title" to lblText.text, but you are passing in a variable you call "text" I don't see where title is defined anywhere.
public final function set title(text:String):void {
trace(lblTitle);
if (lblTitle != null) {
trace(text);
lblTitle.text = title;
trace(lblTitle.text);
}
}
-
2. Re: TextField text changed during parent's container gets reset
xTLS Aug 6, 2012 10:37 AM (in response to Ned Murphy)I won't pretend to follow all of what you just described
Are you not capable of helping people without sticking in some mean comment? I feel like you're here to feel better than everyone else, rather than to actually be helpful. Thank you for the help, anyway, that was a stupid mistake, I seem to be making a lot of those lately... I guess I should sleep more than six hours a night...
-
3. Re: TextField text changed during parent's container gets reset
Ned Murphy Aug 6, 2012 10:51 AM (in response to xTLS)Gee, you are awfully touchy... interpretting what I said as being an insult towards you when it was an indication of my own limitations. I was indicating that I do not easily follow matters that concern classes - but I thought I would point out something that caught my eye. Sorry to have offended you by trying to help.
-
4. Re: TextField text changed during parent's container gets reset
xTLS Aug 6, 2012 11:13 AM (in response to Ned Murphy)Fair enough, sorry about that, I guess I am somewhat touchy >_< . This turned out to be related to a string of misunderstandings and the typo just destroyed the whole thing.
I had found if I did:
private var lblTitle:TextField;
public function MenuBar(text:String) {
lblTitle = TextField(this.getChildByName("lblTitle"));
lblTitle.text = text
}
it would throw a null reference error (I guess because lblTitle hasn't been added to the stage yet? I need to look into that more) so I thought "you can't access the TextField from the constructor" and wrote the set text function and got progressively more confused from there >_<
-
5. Re: TextField text changed during parent's container gets reset
Amy Blankenship Aug 6, 2012 3:09 PM (in response to xTLS)I usually do not try to do constructor injection on View Classes (but then again, I usually allow the Flash Player/timeline to handle the instantiation and population of all my instances). I find that when the Flash player creates timeline instances, all of their children (that are present on frame 1, of course) are accessible from within the constructor, simply by referencing the instance name. So if you did something more like this:
public var menuBarTop:MenuBar;
protected var _title:String='default title';
public function MenuScreen() {
if (menuBarTop) {
menuBarTop.title= 'default title';//this should work fine
}
}
public function get title():String {
return _title;
}
public function set title(value:String) {
if (value != _title) {
_title = value;
if (menuBarTop) {
menuBarTop.title = _title;
}
}
For tighter control, you can use a getter/setter for menuBarTop as well.
So, you're probably wondering how you are going to "get hold" of MenuScreen in order to populate it if you allow Flash to instantiate it? If you're not sure, check out http://www.developria.com/2010/04/combining-the-timeline-with-oo.html or http://www.meetup.com/atlflex/files/ (the files there all relate to this discussion)
-
6. Re: TextField text changed during parent's container gets reset
xTLS Aug 8, 2012 12:25 PM (in response to Amy Blankenship)Thanks, I have a better understanding of what's going on behind the scenes now!




