Using the array methods does not cause the dataProvider events to fire,
which are need to update the control. This is true for all
dataProviders.

Because of this it is best to always use the dataProvider API to work
with the dataProvider. (duh!)

If you really want to use the underlying methods, you can re-assign the
array to the dataProvider. That will cause the control to update.

Tracy

-----Original Message-----
From: Alex [mailto:[EMAIL PROTECTED] On Behalf Of
[EMAIL PROTECTED]
Sent: Wednesday, February 09, 2005 6:01 AM
To: [email protected]
Subject: [flexcoders] FW: Adding elements to TabBar dynamically


Figured it out. 
Haven't initialized dataProvider initially

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml";
theme="themes/mywsc.swc">
<mx:Script>
<![CDATA[
        
function addIt()
{
mytab.dataProvider.addItem({label:"test",data:"test"});
}
var arr:Array=[];
]]>
    
</mx:Script>

<mx:TabBar id="mytab" dataProvider="{arr}"/>
<mx:Button label="click me" click="addIt()"/>
</mx:Application> 

But doesn't work if I use 

arr.push({label:"test",data:"test"}) 

instead of 

mytab.dataProvider.addItem({label:"test",data:"test"});

Any ideas?

Alex.



-----Original Message-----
From: Alex [mailto:[EMAIL PROTECTED] On Behalf Of
[EMAIL PROTECTED]
Sent: Wednesday, February 09, 2005 12:48 PM
To: '[email protected]'
Subject: Adding elements to TabBar dynamically

Hi, 

Not sure why the code below doesn't work, i.e. it doesn't create a new
Tab.

Many thanks,
Alex

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml";>
<mx:Script>
<![CDATA[
        
function addIt()
{
mytab.dataProvider.addItem({label:"test",data:"test"});
mytab.draw();
}
    
]]>
    
</mx:Script>

<mx:TabBar id="mytab" />
<mx:Button label="click me" click="addIt()"/> </mx:Application>



 
Yahoo! Groups Links



 







Reply via email to