You are a star!
Thanks very much, addItem
on the actual array did the trick, I hadn’t thought about doing it this
way.
This will solve a lot of problems!
Thanks again,
Steve
-----Original Message-----
From: flexcoders@yahoogroups.com
[mailto:[EMAIL PROTECTED] On Behalf
Of bhaq1972
Sent: 13 September 2005 15:19
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re:
Array/Dataprovider/Tabbar etc issues.
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 flexcoders@yahoogroups.com, "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
--
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