Be careful here. There is a possible performance problem with a
application level central model. If you push all of your data through a
central model, then whenever you change ANY property in the model a
propertyChangeEvent is thrown from the model class. So  every UI element
in your application which is bound to any property in the central model
will invalidate their display and re-render itself..   even if it's not
on screen. 

 

I'm with mike on this, bubble the data you need up as needed, but, keep
things as local as possible. You might need to go to a global central
model for some data, every app has a little global data (logged in user,
etc). But in practice, most of the data I've ever referenced is usually
pretty specific to a component or two. So I let the child tell the
parent with an event and the parent can decide which other children need
to know. Children can't tell each other what to do. Or in other words,
let the parent component be the "model" for sub-components under it. 

 

Hope that helps,

---nimer

 

 

 

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Alex Harui
Sent: Friday, June 27, 2008 10:38 AM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] Re: One custom component referring to another

 

My vote would be for changes in A to affect a central model.  B would
watch the model change and reflect those changes.  Everything B needs
from A would be reflected in the model.  That's pretty much what Mike
said, except I'm not a fan of "throwing events up" if that means
"bubbling".  A should dispatch events that the app listens to in order
to change the central model.

 

However, I would think that there is some syntax that should have got
this past the compiler.  If you use the MXMLC -keep option you can see
what it generated and maybe figure out why it didn't work.  

 

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Michael Labriola
Sent: Friday, June 27, 2008 8:20 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: One custom component referring to another

 

Jason,

In an ideal world, component A would throw events up. Those events 
would be caught in the application (in this case) and call 
corresponding methods in component B.

You really, really don't want to start coupling these components 
together by calling the internals of one from the other in this way. 
Especially when they really are peers in your application.

Just my 2 cents,
Mike

--- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
, "Merrill, Jason" 
<[EMAIL PROTECTED]> wrote:
>
> I thought this would be simple - having one custom display object 
modify another through a reference:
> 
> <mx:Application >
> <c:MyComponentA />
> <c:MyComponentB />
> </mx:Application>
> 
> I want to have MyComponentA refer to objects/methods inside of 
MyComponentB. I tried passing a reference in:
> 
> <mx:Application >
> <c:MyComponentA id="myComponentA" />
> <c:MyComponentB componentToModify="{myComponentA}"/>
> </mx:Application>
> 
> But I get an error saying, "Access of possibly undefined property 
myComponentA through a reference with static type 
flash.display:DisplayObject."
> 
> I tried calling "parent.myComponentA" from actionscript inside of 
MyComponentB.MXML, but it couldn't find the instance 
of "myComponentA". 
> 
> How do you handle this? I know this probably isn't ideal 
architecture, but would there have to be scripts that listen for 
events in one component in the main app and then modify the other 
component? I guess I could do that if it is best practice. I need 
the two components to be separated because they are two different 
parts of the UI, but need to interact. One has controls that change 
the view and data in the other. Does it have to modify the other 
component from actionscript on the main app or can I just pass a 
reference into one component like I have tried? 
> 
> Thanks.
> 
> 
> Jason Merrill 
> Bank of America 
> Global Technology & Operations & Global Risk L&LD 
> eTools & Multimedia 
> 
> Join the Bank of America Flash Platform Developer Community 
<blocked::http://sharepoint.bankofamerica.com/sites/tlc/flash/default
.aspx> 
> 
> Are you a Bank of America associate interested in innovative 
learning ideas and technologies?
> Check out our internal GT&O Innovative Learning Blog 
<blocked::http://sharepoint.bankofamerica.com/sites/ddc/rd/blog/defau
lt.aspx> & subscribe 
<blocked::http://sharepoint.bankofamerica.com/sites/ddc/rd/blog/_layo
uts/SubNew.aspx?List=\{41BD3FC9-BB07-4763-B3AB-A6C7C99C5B8D\}
&Source=http://sharepoint.bankofamerica.com/sites/ddc/rd/blog/Lists/P
osts/Archive.aspx> .
>

 

Reply via email to