Hi,  i did a simple test (below)

<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml"; >
        <mx:Script>
        <![CDATA[
                var dp:Array = [{ label:"one", data:"two" },
                                        { label:"four", 
data:"five" },
                                        { label:"seven", 
data:"eight" },
                                        { label:"ten", 
data:"eleven" },
                                        { label:"thirteen", 
data:"fourteen" }];


                function doClick()
                {
                        dp.addItem({label:"xx", data:"xx"});
                        //or uncomment next 2 lines
                        //dp.push({label:"xx", data:"xx"});
                        //dp.dispatchEvent({type:"modelChanged"});
                }
        ]]>
        </mx:Script>

        <mx:TabBar id="tb1" dataProvider="{dp}"/>
        <mx:List id="list1" dataProvider="{dp}"/>
        <mx:TabBar id="tb2" dataProvider="{dp}"/>

        <mx:Button label="test" click="doClick()" />
</mx:Application>


Now, if you declare your array (eg dp) at the application level. 
then you could reference it in your components as 
mx.core.Application.Application.dp 

eg
<mx:TabBar dataProvider="{mx.core.Application.application.dp}"/>

mx.core.Application.application.dp.addItem({label:"xx", data:"xx"})

and all components using dp should get updated. 


Bod






--- In [email protected], "Steve Cox" <[EMAIL PROTECTED]> wrote:
> All,
>  
> I've currently got a large amount of components in an app I'm 
making.
> All these components use the dataprovider to fill them.
>  
> Now I'm aware the tabBar component expects an array for the
> dataprovider, but as arrays don't fire change event, the tabbar 
won't
> update. Thus I'd be forced to use: tabbar.dataProvider.addItem() 
>  
> Now I'm sure I'm not the only one that thinks this is pretty 
stupid way
> of doing things? I thought the whole point of using dataproviders 
is to
> be able to share information stored in one place, modify that
> information and everything will slip in line. Now what happens 
when I
> have more than one tabbar pointing to the same dataprovider? I 
obviously
> can't use .addItem on all of them. Does adding items to a 
dataprovider
> in this fashion fire a changed event, thus updating other tabbars?
>  
> I've no doubts I'm either 'not getting it', or just not using 
things the
> right way.. If someone could point me in the right direction, 
that'd be
> great. 
>  
> The general format of my arrays is:
>  
> Array[   {label:"label",data:"data"},
> {label:"label",data:"data"}
>             ]
>  
> Nothing fancy, just an array of objects which nicely fills 
listboxes
> etc.
>  
> Cheers,
>  
> Steve




------------------------ Yahoo! Groups Sponsor --------------------~--> 
Most low income households are not online. Help bridge the digital divide today!
http://us.click.yahoo.com/cd_AJB/QnQLAA/TtwFAA/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