This is a common programming "error".  The scope for all methods is the
class and the class has some properties like x,y,name and a few other
things that folks like to use as temp variables.  If you forget to
declare the var then it uses the class property instead.

 

As a practice,we use i, j, k in our loops.

 

                        private function addMore():void

                        {

                                    var newVBox:VBox;

                                    var newLabel:Label;

                                    for (var y:int = 0; y < 3; y++)

                                    {

                                                newVBox = new VBox;

                                                newVBox.label= "Added "
+ y;

                                                newLabel = new Label;

                                                newLabel.text = "Hello "
+ newVBox.label;

 
newVBox.addChild(newLabel);

 
newVBox.addEventListener("doSomething", doSomethingNow);

                                                nav.addChild(newVBox);

                                    }

                        }

 

________________________________

From: [email protected]
[mailto:[EMAIL PROTECTED] On Behalf Of loc_tran106
Sent: Monday, March 12, 2007 12:48 PM
To: [email protected]
Subject: [flexcomponents] Re: TitleWindow Problem

 

did *not* fix the problem :) 

--- In [email protected]
<mailto:flexcomponents%40yahoogroups.com> , "loc_tran106"
<[EMAIL PROTECTED]>
wrote:
>
> Thanks Dan for the suggestion, but that's not it;
> vertical/absolute/horizontal fix the problem (in my example below, the
> layout isn't specified so i think the default is already absolute)
> 
> This is proving very frustrating.
> 
> -Loc
> 
> --- In [email protected]
<mailto:flexcomponents%40yahoogroups.com> , "Daniel Freiman"
> <FreimanCQ@> wrote:
> >
> > My guess is that Application defaults to layout=vertical which means
> that
> > you're Application acts a little like a VBox. Every time you add a
> tab it
> > must be indirectly calling updateDisplayList on the Application. Set
> > layout=absolute and see if that fixes it.
> > 
> > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> "
> layout="absolute">
> > 
> > - Dan Freiman
> > 
> > On 09 Mar 2007 15:22:52 -0800, loc_tran106 <loc_tran106@> wrote:
> > >
> > > Hello All,
> > >
> > > I have a problem that is bugging me big time. I'm writing a new
> > > component for one of my applications which extends a titlewindow.
> > >
> > > Each titlewindow contains a tabnavigator, and I programically
> > > add/remove tabs to the tabnav. However, everytime I do that, the
> > > titlewindow itself moves to the top of the screen and I have no
> clue why.
> > >
> > > Can someone help explain to me what causes this problem? when you
> > > click on "Add 3 more tabs" button?
> > >
> > > TIA.
> > >
> > > -Loc
> > >
> > > Main Application:
> > >
> > > <?xml version="1.0" encoding="utf-8"?>
> > > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> " >
> > > <mx:Script>
> > > <![CDATA[
> > > import mx.managers.PopUpManager;
> > >
> > > private var tmpWindow:windowBug;
> > >
> > > private function PopMeUp():void {
> > > tmpWindow =
> > > windowBug(PopUpManager.createPopUp(mainCanvas,windowBug,false));
> > > PopUpManager.centerPopUp(tmpWindow);
> > > }
> > > ]]>
> > > </mx:Script>
> > > <mx:Canvas width="100%" height="100%" id="mainCanvas" >
> > > <mx:Button click="PopMeUp()" label="Click Here" />
> > > </mx:Canvas>
> > > </mx:Application>
> > >
> > > Component: (windowBug.mxml)
> > >
> > > <?xml version="1.0" encoding="utf-8"?>
> > > <mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> "
> > > layout="vertical" width="400" height="300" title="Bug Test">
> > > <mx:Script>
> > > <![CDATA[
> > > import mx.controls.Label;
> > > import mx.containers.VBox;
> > > import mx.events.*;
> > >
> > > private function addMore():void {
> > > var newVBox:VBox;
> > > var newLabel:Label;
> > > for (y=0; y<3; y++) {
> > > newVBox = new VBox;
> > > newVBox.label= "Added " + y;
> > > newLabel = new Label;
> > > newLabel.text = "Hello " + newVBox.label;
> > > newVBox.addChild(newLabel);
> > > newVBox.addEventListener("doSomething",doSomethingNow);
> > > nav.addChild(newVBox);
> > > }
> > > }
> > >
> > > private function doSomethingNow(event:Event):void {
> > > trace ('nada');
> > > }
> > >
> > > ]]>
> > > </mx:Script>
> > > <mx:Button click="addMore()" label="Add 3 More Tabs" />
> > > <mx:TabNavigator id="nav">
> > > <mx:VBox label="1" >
> > > <mx:Label text="Hello 1" />
> > > </mx:VBox>
> > > <mx:VBox label="2" >
> > > <mx:Label text="Hello 2" />
> > > </mx:VBox>
> > > <mx:VBox label="3" >
> > > <mx:Label text="Hello 3" />
> > > </mx:VBox>
> > > <mx:VBox label="4" >
> > > <mx:Label text="Hello 4" />
> > > </mx:VBox>
> > > </mx:TabNavigator>
> > > </mx:TitleWindow>
> > >
> > > 
> > >
> >
>

 

Reply via email to