Re: [flexcoders] Re: Detect if Object exists

2006-07-21 Thread Ralf Bokelberg



Hi Nick, 

you could use something like an itemRenderer as the tab and its data
property to compare against the selected item of your data grid.
Here is a simple example: 

 snip  
?xml version=1.0 encoding=utf-8?
mx:Application xmlns:mx=http://www.adobe.com/2006/mxml 
 layout=vertical
 mx:Script
  ![CDATA[
  
   import mx.collections.ArrayCollection;
   
   [Bindable]
   private var people : ArrayCollection = initPeople();
   
   private function initPeople() : ArrayCollection
   {
  
 var result : ArrayCollection = new ArrayCollection();
result.addItem(John Miller);
result.addItem(Steve Jones);
result.addItem(Ramirez Maria Santa Cruz);
return result;
   }
   
   private function showInTab( event : Event ) : void
   {
  
 var selectedItem : String =
event.target.selectedItem as String; 
var tab : MyTab = findTab( selectedItem );
if( tab == null )
{
 tab = createTab( selectedItem );
 tn.addChild( tab );
} 
tn.selectedChild = tab;
   }
   
   private function findTab( item : * ) : MyTab
   {
var numChildren : int = tn.numChildren;
for( var i : int = 0; i  numChildren; i++ )
{
  
  var tab : MyTab = tn.getChildAt(
i ) as MyTab;
 if( tab.data == item )
 {
  
   return
tab; 
 }
} 
return null;
   }
   
   private function createTab( item : * ) : MyTab
   {
var result : MyTab = new MyTab();
result.data = "">
return result; 
   }
   
  ]]
 /mx:Script
 mx:ComboBox dataProvider={ people } change=showInTab( event )/
 mx:TabNavigator id=tn width=500/
/mx:Application

 snip  
?xml version=1.0 encoding=utf-8?
mx:VBox xmlns:mx=http://www.adobe.com/2006/mxml 
 width=100% height=100%
 label={ renderLabel( data )}
 
 mx:Script
  ![CDATA[
   private function renderText( data : Object ) : String
   {
return data as String;
   }
   private function renderLabel( data : Object ) : String
   {
return data as String;
   }
  ]]
 /mx:Script
 mx:Label text={ renderText( data )} /
/mx:VBox

 snip  

Cheers,
Ralf. On 7/21/06, Nick Collins [EMAIL PROTECTED] wrote:



I tried something very similar to that, but got the following error, as I did this time:1118: Implicit coercion of a value with static type flash.display:DisplayObject to a possibly unrelated type mx.core:Container.

On 7/20/06, fwscott 
[EMAIL PROTECTED] wrote:













  



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 

Re: [flexcoders] Re: Detect if Object exists

2006-07-21 Thread Scotty Scott



Change
var selectTab:Container = this.windowTabs.getChildByName(newid);to
var selectTab:Container = Container(this.windowTabs.getChildByName(newid));Or
var selectTab:Container = this.windowTabs.getChildByName(newid) as Container;Im not sure which syntax is the correct way or what the difference is. Anyone care to explain the difference?Scotty
On 7/20/06, Nick Collins [EMAIL PROTECTED] wrote:













  



I tried something very similar to that, but got the following error, as I did this time:1118: Implicit coercion of a value with static type flash.display:DisplayObject to a possibly unrelated type mx.core:Container
.
On 7/20/06, fwscott 
[EMAIL PROTECTED] wrote:













  



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?



  















  















__._,_.___





--
Flexcoders Mailing List
FAQ: 

Re: [flexcoders] Re: Detect if Object exists

2006-07-21 Thread Nick Collins



Hmm... well Scotty, interestingly enough, this train of thought isn't working... for some reason the condition is always returning true, even when no tabs at all have been created... back to the drawing board I guess.
On 7/20/06, Scotty Scott [EMAIL PROTECTED] wrote:













  



Change
var selectTab:Container = this.windowTabs.getChildByName(newid);to
var selectTab:Container = Container(this.windowTabs.getChildByName(newid));Or
var selectTab:Container = this.windowTabs.getChildByName(newid) as Container;Im not sure which syntax is the correct way or what the difference is. Anyone care to explain the difference?Scotty

On 7/20/06, Nick Collins 
[EMAIL PROTECTED] wrote:













  



I tried something very similar to that, but got the following error, as I did this time:1118: Implicit coercion of a value with static type flash.display:DisplayObject to a possibly unrelated type mx.core:Container

.
On 7/20/06, fwscott 

[EMAIL PROTECTED] wrote:













  



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 

Re: [flexcoders] Re: Detect if Object exists

2006-07-21 Thread Scotty Scott



Hey Nick,I used this as a test case its stripped down from what you are doing but maybe it will point you in the right direction.?xml version=1.0 encoding=utf-8?
mx:Application xmlns:mx=http://www.adobe.com/2006/mxml layout=vertical creationComplete=init()
 mx:Script  ![CDATA[
   import mx.containers.Canvas;   import mx.core.Container;
   private function init():void {trace(tabExists('test'));
windowTab.addChild(newTab('test'));
trace(tabExists('test'));trace(tabExists('test2'));
windowTab.addChild(newTab('test2'));   trace(tabExists('test2'));
trace(tabExists('test3'));}
   private function tabExists(str:String):Boolean {return windowTab.getChildByName
(str) != null;   }   private function newTab(str:String):Canvas {
var tmpcon:Canvas = new Canvas();
tmpcon.percentWidth = 100;tmpcon.percentHeight = 100;
tmpcon.id = str;tmpcon.name = str; 
tmpcon.label = str;return tmpcon;   }
  ]] /mx:Script
mx:TabNavigator id=windowTab width=100% height=100% /mx:TabNavigator
/mx:Applicationshows in the console:falsetrue
falsetruefalse
Maybe we need to just change the if statement so it checks for nullif ( selectTab != null )Scotty
On 7/21/06, Nick Collins [EMAIL PROTECTED] wrote:













  



Hmm... well Scotty, interestingly enough, this train of thought isn't working... for some reason the condition is always returning true, even when no tabs at all have been created... back to the drawing board I guess.

On 7/20/06, Scotty Scott 
[EMAIL PROTECTED] wrote:













  



Change
var selectTab:Container = this.windowTabs.getChildByName(newid);to
var selectTab:Container = Container(this.windowTabs.getChildByName(newid));Or
var selectTab:Container = this.windowTabs.getChildByName(newid) as Container;Im not sure which syntax is the correct way or what the difference is. Anyone care to explain the difference?Scotty


On 7/20/06, Nick Collins 

[EMAIL PROTECTED] wrote:













  



I tried something very similar to that, but got the following error, as I did this time:1118: Implicit coercion of a value with static type flash.display:DisplayObject to a possibly unrelated type mx.core:Container


.
On 7/20/06, fwscott 


[EMAIL PROTECTED] wrote:













  



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 

Re: [flexcoders] Re: Detect if Object exists

2006-07-21 Thread Nick Collins



if ( selectTab != null )That did it! Woot!!! Thanks man. This thing has been a pain in my butt for the last week.On 7/21/06, Scotty Scott 
[EMAIL PROTECTED] wrote:












  



Hey Nick,I used this as a test case its stripped down from what you are doing but maybe it will point you in the right direction.
?xml version=1.0 encoding=utf-8?
mx:Application xmlns:mx=
http://www.adobe.com/2006/mxml layout=vertical creationComplete=init()
 mx:Script  ![CDATA[

   import mx.containers.Canvas;   import mx.core.Container;

   private function init():void {trace(tabExists('test'));
windowTab.addChild(newTab('test'));

trace(tabExists('test'));trace(tabExists('test2'));

windowTab.addChild(newTab('test2'));   trace(tabExists('test2'));

trace(tabExists('test3'));}

   private function tabExists(str:String):Boolean {return windowTab.getChildByName

(str) != null;   }   private function newTab(str:String):Canvas {
var tmpcon:Canvas = new Canvas();
tmpcon.percentWidth = 100;tmpcon.percentHeight = 100;

tmpcon.id = str;
tmpcon.name = str; 
tmpcon.label = str;return tmpcon;   }
  ]] /mx:Script

mx:TabNavigator id=windowTab width=100% height=100% /mx:TabNavigator

/mx:Applicationshows in the console:falsetrue

falsetruefalse

Maybe we need to just change the if statement so it checks for nullif ( selectTab != null )Scotty

On 7/21/06, Nick Collins 
[EMAIL PROTECTED] wrote:













  



Hmm... well Scotty, interestingly enough, this train of thought isn't working... for some reason the condition is always returning true, even when no tabs at all have been created... back to the drawing board I guess.

On 7/20/06, Scotty Scott 

[EMAIL PROTECTED] wrote:













  



Change
var selectTab:Container = this.windowTabs.getChildByName(newid);to
var selectTab:Container = Container(this.windowTabs.getChildByName(newid));Or
var selectTab:Container = this.windowTabs.getChildByName(newid) as Container;Im not sure which syntax is the correct way or what the difference is. Anyone care to explain the difference?Scotty



On 7/20/06, Nick Collins 


[EMAIL PROTECTED] wrote:













  



I tried something very similar to that, but got the following error, as I did this time:1118: Implicit coercion of a value with static type flash.display:DisplayObject to a possibly unrelated type mx.core:Container



.
On 7/20/06, fwscott 



[EMAIL PROTECTED] wrote:













  



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 

[flexcoders] Re: Detect if Object exists

2006-07-20 Thread fwscott
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/
 




Re: [flexcoders] Re: Detect if Object exists

2006-07-20 Thread Nick Collins



I tried something very similar to that, but got the following error, as I did this time:1118: Implicit coercion of a value with static type flash.display:DisplayObject to a possibly unrelated type mx.core:Container.
On 7/20/06, fwscott [EMAIL PROTECTED] wrote:













  



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?



  















__._,_.___





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








   






  
  
SPONSORED LINKS
  
  
  

Web site design development
  
  
Computer software development
  
  
Software design and development
  
  


Macromedia flex