[flexcoders] Re: One custom component referring to another

2008-06-27 Thread Merrill, Jason
Well, we're using Cairngorm on this project, so I think I'm going to use 
Cairngorm events and commands and centralize this, instead of trying to 
establish any tight coupling between components.  It's a control bar with 
checkboxes effecting the view of another visual componet in another part of the 
app.  Thanks everyone, great discussion.

Jason Merrill 
Bank of America 
Global Technology & Operations & Global Risk L&LD 
eTools & Multimedia 

Join the Bank of America Flash Platform Developer Community  
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 
http://sharepoint.bankofamerica.com/sites/ddc/rd/blog/default.aspx>  
& subscribe 
http://sharepoint.bankofamerica.com/sites/ddc/rd/blog/_layouts/SubNew.aspx?List=\{41BD3FC9-BB07-4763-B3AB-A6C7C99C5B8D\}&Source=http://sharepoint.bankofamerica.com/sites/ddc/rd/blog/Lists/Posts/Archive.aspx>
 . 




RE: [flexcoders] Re: One custom component referring to another

2008-06-27 Thread Alex Harui
I think that's if you actually use   I generally write my own
model singletons and customize the change events.  IMHO, it also makes
it easier to reflect the model in the URL in BrowserMgr.  But the two
Mikes actually do this for money and I don't so maybe there's stuff they
know that makes a difference.

 



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

 

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:
> 
> 
> 
> 
> 
> 
> I want to have MyComponentA refer to objects/methods inside of 
MyComponentB. I tried passing a reference in:
> 
> 
> 
> 
> 
> 
> 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 
http://sharepoint.bankofamerica.com/sites/tlc/flash/default
<http://sharepoint.bankofamerica.com/sites/tlc/flash/default> 
.aspx> 
> 
> Are you a Bank of America associ

[flexcoders] Re: One custom component referring to another

2008-06-27 Thread Amy
--- In flexcoders@yahoogroups.com, "Jason" <[EMAIL PROTECTED]> wrote:
>
> Thanks Alex and Mike, I was kinda starting to suspect I needed to 
do 
> it that way, even as I was writing the e-mail.  Makes perfect 
sense, 
> I'll do that. Thanks!

It's not best practice, but you absolutely can pass references to 
things outside an object's scope into the object.  I did this with a 
component I wanted to "reparent," i.e. I had a series of components 
duplicated in a Repeater, and when you clicked on one of them, it 
would grab the component I'd passed a reference to and add it to 
itself.  I was doing this to make something that looked like an 
Accordion but could take a dataprovider and recycle the same object 
rather than having multiple copies.

Essentially, you just put a property on the component with type 
UIComponent and push it in through the ClassFactory if it is an 
itemRenderer or you can set it directly if it is not.

If you set up an interface that the component you are referring to 
has to adhere to, you can actually do this without requiring tight 
coupling.  I didn't need to worry about that, because the only thing 
I did was addChild().  However, you may want to consider just having 
the components bound to the same data and have the data push the 
changes.

HTH;

Amy





RE: [flexcoders] Re: One custom component referring to another

2008-06-27 Thread Mike Nimer
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:
> 
> 
> 
> 
> 
> 
> I want to have MyComponentA refer to objects/methods inside of 
MyComponentB. I tried passing a reference in:
> 
> 
> 
> 
> 
> 
> 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 
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 
http://sharepoint.bankofamerica.com/sites/ddc/rd/blog/defau
lt.aspx> & subscribe 
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> .
>

 



[flexcoders] Re: One custom component referring to another

2008-06-27 Thread Jason
Thanks Alex and Mike, I was kinda starting to suspect I needed to do 
it that way, even as I was writing the e-mail.  Makes perfect sense, 
I'll do that. Thanks!

Jason Merrill 
Bank of America 
Global Technology & Operations & Global Risk L&LD 
eTools & Multimedia 

Join the Bank of America Flash Platform Developer Community 

Are you a Bank of America associate interested in innovative learning 
ideas and technologies?
Check out our internal  GT&O Innovative Learning Blog & subscribe.

 

--- In flexcoders@yahoogroups.com, "Alex Harui" <[EMAIL PROTECTED]> wrote:
>
> 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" 
>  wrote:
> >
> > I thought this would be simple - having one custom display object 
> modify another through a reference:
> > 
> > 
> > 
> > 
> > 
> > 
> > I want to have MyComponentA refer to objects/methods inside of 
> MyComponentB. I tried passing a reference in:
> > 
> > 
> > 
> > 
> > 
> > 
> > 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 
> 
http://sharepoint.bankofamerica.com/sites/tlc/flash/default
> <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 
> 
http://sharepoint.bankofamerica.com/sites/ddc/rd/blog/defau
> <http://sharepoint.bankofamerica.com/sites/ddc/rd/blog/defau> 
> lt.aspx> & subscribe 
> 
http://sharepoint.bankofamerica.com/sites/ddc/rd/blog/_layo
> <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
> <http://sharepoint.bankofamerica.com/sites/ddc/rd/blog/Lists/P> 
> osts/Archive.aspx> .
> >
>




RE: [flexcoders] Re: One custom component referring to another

2008-06-27 Thread Alex Harui
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:
> 
> 
> 
> 
> 
> 
> I want to have MyComponentA refer to objects/methods inside of 
MyComponentB. I tried passing a reference in:
> 
> 
> 
> 
> 
> 
> 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 
http://sharepoint.bankofamerica.com/sites/tlc/flash/default
<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 
http://sharepoint.bankofamerica.com/sites/ddc/rd/blog/defau
<http://sharepoint.bankofamerica.com/sites/ddc/rd/blog/defau> 
lt.aspx> & subscribe 
http://sharepoint.bankofamerica.com/sites/ddc/rd/blog/_layo
<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
<http://sharepoint.bankofamerica.com/sites/ddc/rd/blog/Lists/P> 
osts/Archive.aspx> .
>

 



[flexcoders] Re: One custom component referring to another

2008-06-27 Thread Michael Labriola
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, "Merrill, Jason" 
<[EMAIL PROTECTED]> wrote:
>
> I thought this would be simple - having one custom display object 
modify another through a reference:
> 
> 
>   
>   
> 
> 
> I want to have MyComponentA refer to objects/methods inside of 
MyComponentB.  I tried passing a reference in:
> 
> 
>   
>   
> 
> 
> 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  
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 
http://sharepoint.bankofamerica.com/sites/ddc/rd/blog/defau
lt.aspx>  & subscribe 
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> .
>