         targetStack.addEventListener(IndexChangedEvent.CHILD_INDEX_CHANGE,
                                      childIndexChangeHandler);
 
-        var numViews:int = targetStack.numChildren;
-
-        for (var i:int = 0; i < numViews; i++)
-        {
-            var child:Container = Container(targetStack.getChildAt(i));
+        numViews = targetStack.numChildren;
+
+        for (i = 0; i < numViews; i++)
+        {
+            child = Container(targetStack.getChildAt(i));
             var item:Button = Button(createNavItem(itemToLabel(child), child.icon));
 
                  

        // such as when a TabBar is inside a TabNavigator.
        if (event.target == this)
            return;

        var viewStack:ViewStack = ViewStack(event.target);
        removeChildAt(viewStack.getChildIndex(event.relatedObject));

				"controls", "errWrongContainer", [ id ]);
            throw new Error(message);
        }
		
        if (_dataProvider)
        {
            // use weak reference
            _dataProvider.removeEventListener(CollectionEvent.COLLECTION_CHANGE,
                                              collectionChangeHandler);
        }

        // If value is a string, try to resolve here.
        // If value is a ViewStack name, document[value] may not be defined yet.
