Hey Nick,

You could assign a name to your tab and then use
this.windowTabs.getChildByName(newtab.name);

Something like

private function createTab(createTabName:String):void
  {
    var newid:String = 'userTab' +
this.masterList.selectedItem.ContribNum;
    var selectTab:Container = this.windowTabs.getChildByName(newid);
    if(!selectTab) {
                 var newVbox:VBox = new VBox();
                 var newHbox:HBox = new HBox();
                 var newTab:Canvas = new Canvas();
                 var newSpacer:Spacer = new Spacer();
                 var tabCloseBtn:Button = new Button();
 
                 // create button to close tab
                 tabCloseBtn.label = "Close Tab";
                 tabCloseBtn.addEventListener
(MouseEvent.CLICK,myClickListener);
 
                 // create spacer to position close button
                 newSpacer.percentWidth = 100;
 
                 // create box layout controls
                 newHbox.percentWidth = 100;
                 newHbox.addChild(newSpacer);
                 newHbox.addChild(tabCloseBtn);
                 newVbox.addChild(newHbox);
                 newVbox.addChild
(getTithesComponent(this.masterList.selectedItem.ContribNum));
 
                 // create tab
                 newTab.label = createTabName;
                 newTab.id = newid;
                 newTab.name = newid;
           
                 newTab.addChild(newVbox);
 
                 this.windowTabs.addChild(newTab);
                 this.windowTabs.selectedChild = newTab;
                 }
                      
     else
         this.windowTabs.selectedChild = selectTab;
   }

Scotty
http://www.franciswscott.com


--- In flexcoders@yahoogroups.com, "Nick Collins" <[EMAIL PROTECTED]> wrote:
>
> I've got a datagrid with a list of people, that when you double click on
> one, it creates a new tab with that person's data into a
TabNavigator. I'm
> trying to get it so it will only open one instance of a tab for each
person,
> and if you try to open a person again, it will simply select their
tab that
> already exists. Sounds pretty straightforward, right?
> 
> Here's what I've got, when you click the button for their data or double
> click their name, an event is launched which then calls this function,
> createTab:
> 
> private function createTab(createTabName:String):void
>             {
>                 var newVbox:VBox = new VBox();
>                 var newHbox:HBox = new HBox();
>                 var newTab:Canvas = new Canvas();
>                 var newSpacer:Spacer = new Spacer();
>                 var tabCloseBtn:Button = new Button();
> 
>                 // create button to close tab
>                 tabCloseBtn.label = "Close Tab";
>                 tabCloseBtn.addEventListener (MouseEvent.CLICK,
> myClickListener);
> 
>                 // create spacer to position close button
>                 newSpacer.percentWidth = 100;
> 
>                 // create box layout controls
>                 newHbox.percentWidth = 100;
>                 newHbox.addChild(newSpacer);
>                 newHbox.addChild(tabCloseBtn);
>                 newVbox.addChild(newHbox);
>                 newVbox.addChild (getTithesComponent(
> this.masterList.selectedItem.ContribNum));
> 
>                 // create tab
>                 newTab.label = createTabName;
>                 newTab.id = 'userTab' +
> this.masterList.selectedItem.ContribNum ;
>                 newTab.addChild(newVbox);
> 
>                 var selectTab:ObjectName = newTab.id;
> 
>                 if (!selectTab) {
>                     this.windowTabs.selectedChild = selectTab;
>                 } else {
>                     this.windowTabs.addChild(newTab);
>                     this.windowTabs.selectedChild = newTab;
>                 }
> 
>             }
> 
> Now from the docs I've found, it seems like doing an if statement
with the
> condition of ! objectID should be checking if that id exists, right? for
> some reason it always returns false, even when a new canvas in the
> TabNavigator stack with that id value already exists.
> 
> Any ideas how I can accurately detect if the object exists?
>






------------------------ Yahoo! Groups Sponsor --------------------~--> 
See what's inside the new Yahoo! Groups email.
http://us.click.yahoo.com/2pRQfA/bOaOAA/yQLSAA/nhFolB/TM
--------------------------------------------------------------------~-> 

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to