Re: [flexcoders] custom component dataprovider

2008-04-21 Thread gabriel montagné
On Fri, Apr 18, 2008 at 6:50 PM, Tracy Spratt [EMAIL PROTECTED] wrote:
 dataprovider again, right?  I had assumed that implementing a dataprovider
 would make updates to the UI cleaner (not having to re-create all items),
 but I could be wrong on that assumption- don't know yet.


I like to do it like this:

[Bindable]
public function set dataProvider(value :Object) :void {

if (_dataProvider) {
_dataProvider.removeEventListener(
CollectionEvent.COLLECTION_CHANGE,
onDataChange,
false
);
}

_dataProvider   =   (value is Array)? new
ArrayCollection(value as Array)
:   (value is IList)? IList(value)
:   (value is XMLList)  ? new
XMLListCollection(value as XMLList)
:   new ArrayCollection()
;

_dataProvider.addEventListener(
CollectionEvent.COLLECTION_CHANGE,
onDataChange,
false,
0,
true
);

_dataChanged = true;

   etc. etc. etc.


Re: [flexcoders] custom component dataprovider

2008-04-21 Thread gabriel montagné
On Sun, Apr 20, 2008 at 9:38 PM, gabriel montagné [EMAIL PROTECTED] wrote:

  I like to do it like this:

 _dataProvider   =   (value is Array)? new

where _dataProvider is typed IList..

... pretty useful and flexible...  I'd read it (or something like it)
on one Ely Greenfield's carousel, I think..

-- 
gabriel montagné láscaris comneno
http://rojored.com
t/506.8392.2040


RE: [flexcoders] custom component dataprovider

2008-04-18 Thread Tracy Spratt
Just implement a public setter function on your component that takes
XML.

 

In the setter, launch your child instantiation code.  I have done this
and it  can be a bit complex, but is not hard.

 

Tracy

 

 

 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Derrick Anderson
Sent: Friday, April 18, 2008 1:16 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] custom component dataprovider

 

hey everyone,

i'm trying to build a custom component based off of a Panel, but the
trick is that I would like the panel to accept xml as a dataprovider.
where are there any good tutorials on building custom components with
dataproviders?

btw, the goal is to take an xml node in the dataprovider (box x=10
y=15panel title=test panel //box) and convert them to UI
components.  Any ideas?

thanks,
d.

 



Re: [flexcoders] custom component dataprovider

2008-04-18 Thread Derrick Anderson
Hey Tracy,

I thought of that but it seems to limit me from what I'm trying to do.  I
need the UI of this component to respond when the dataprovider changes, I
figured the best way would be to implement a dataprovider the way the mx
components do it, it seems complicated but I'm getting throught it.  Then if
I changed the model, the UI would update appropriately.  If i just implement
the child creation in the setter, then I have to re-parse the whole
dataprovider again, right?  I had assumed that implementing a dataprovider
would make updates to the UI cleaner (not having to re-create all items),
but I could be wrong on that assumption- don't know yet.

d.

On Fri, Apr 18, 2008 at 5:26 PM, Tracy Spratt [EMAIL PROTECTED] wrote:

Just implement a public setter function on your component that takes
 XML.



 In the setter, launch your child instantiation code.  I have done this and
 it  can be a bit complex, but is not hard.



 Tracy






  --

 *From:* flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] *On
 Behalf Of *Derrick Anderson
 *Sent:* Friday, April 18, 2008 1:16 PM
 *To:* flexcoders@yahoogroups.com
 *Subject:* [flexcoders] custom component dataprovider



 hey everyone,

 i'm trying to build a custom component based off of a Panel, but the trick
 is that I would like the panel to accept xml as a dataprovider.  where are
 there any good tutorials on building custom components with dataproviders?

 btw, the goal is to take an xml node in the dataprovider (box x=10
 y=15panel title=test panel //box) and convert them to UI
 components.  Any ideas?

 thanks,
 d.

  



RE: [flexcoders] custom component dataprovider

2008-04-18 Thread Tracy Spratt
The setter is just an interface into your component property.  How you
implement the functionality is up to you and is unlimited.  You can bind
your property to whatever in the app, and the setter will be called when
the model changes.  The Adobe components implement the dataProvider with
a setter I'm sure.

 

If you pass xml into the component in the dataProvider property it will
not need to be parsed again.  Again, how you respond to the property
change is up to you.  If you are talking about recycling your
children, then that is not about the dataprovider, but about your
response to the model change.

 

But if you are on track, then keep going.

 

Tracy

 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Derrick Anderson
Sent: Friday, April 18, 2008 8:02 PM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] custom component dataprovider

 

Hey Tracy,

I thought of that but it seems to limit me from what I'm trying to do.
I need the UI of this component to respond when the dataprovider
changes, I figured the best way would be to implement a dataprovider the
way the mx components do it, it seems complicated but I'm getting
throught it.  Then if I changed the model, the UI would update
appropriately.  If i just implement the child creation in the setter,
then I have to re-parse the whole dataprovider again, right?  I had
assumed that implementing a dataprovider would make updates to the UI
cleaner (not having to re-create all items), but I could be wrong on
that assumption- don't know yet.

d.

On Fri, Apr 18, 2008 at 5:26 PM, Tracy Spratt [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]  wrote:

Just implement a public setter function on your component that takes
XML.

 

In the setter, launch your child instantiation code.  I have done this
and it  can be a bit complex, but is not hard.

 

Tracy

 

 

 



From: flexcoders@yahoogroups.com mailto:flexcoders@yahoogroups.com
[mailto:flexcoders@yahoogroups.com mailto:flexcoders@yahoogroups.com ]
On Behalf Of Derrick Anderson
Sent: Friday, April 18, 2008 1:16 PM
To: flexcoders@yahoogroups.com mailto:flexcoders@yahoogroups.com 
Subject: [flexcoders] custom component dataprovider

 

hey everyone,

i'm trying to build a custom component based off of a Panel, but the
trick is that I would like the panel to accept xml as a dataprovider.
where are there any good tutorials on building custom components with
dataproviders?

btw, the goal is to take an xml node in the dataprovider (box x=10
y=15panel title=test panel //box) and convert them to UI
components.  Any ideas?

thanks,
d.