PDA

View Full Version : Need advice in managing a "header" textfield



dragonfly
June 2nd, 2009, 03:04 PM
I've got a function, based on the Flash help files called configureHeader();



private function configureHeader():void {
tfHeader = new TextField();
tfHeader.autoSize = TextFieldAutoSize.LEFT;
tfHeader.selectable = false;
tfHeader.embedFonts = true;
tfHeader.y = 20;

var titleFormat:TextFormat = new TextFormat;
titleFormat.color = 0xFFFFFF;
titleFormat.font = myFont.fontName;
titleFormat.size = 48;

tfHeader.defaultTextFormat = titleFormat;
addChild(tfHeader);
trace(getChildIndex(tfHeader))
}
The application is a multipage kiosk project. It starts with a homepage with no header, then a sub nav with the header, and then it goes one page deeper than that with the same header, but new text.

For the sub page function I call:


configureHeader();
tfHeader.text = title;
tfHeader.x = (stage.stageWidth/2) - (tfHeader.width/2);
For the sub-sub page I only call:


tfHeader.text = title;
tfHeader.x = (stage.stageWidth/2) - (tfHeader.width/2);
So as to only repopulate the header text. The question I have is that, when the user touches my "Back" button on the sub-sub page, I again call the function that loads the previously loaded sub page. That means I'm calling the configureHeader() function again... This appears to work the way I want it to, but I notice when tracing the childIndex of the tfHeader TextField that the index keeps increasing.

Will this cause issues? Whats happening to the previously added children? And what happens when/if that index number gets too high? Isn't there a limit?

Please let me know if I need to worry about this and if so, is there a better way.

Thanks!

cbeech
June 2nd, 2009, 03:47 PM
perhaps start your configureHeader method with a line like:


if(contains(tfHeader)) return;