I am slowly becoming comfortable with using event driven functionality, so this opinion is only that.
However, the primary benefit of "loose coupling" is re-usability, and maybe "maintainability", in the sense that it will be easier to drop-in replacement parts. (any others, anyone?). But event code is a little harder to write read and debug than straight calls to directly referenced members. If you are reasonably sure what you are building will not need to be re-used, then there may be little benefit in the effort to gain loose coupling. So "wrong"? No. "Best practice"? It depends. Think ahead. Tracy ________________________________ From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of qnotemedia Sent: Tuesday, December 05, 2006 12:19 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: TitleWindow Component...help! Well - what I've done, after finding a titlewindow example on cflex, is create a public variable in the titlewindow component of the same name as one in the application, and I send it to the component from the main app AND back via the title window's instance variable. i.e.: TitleWindow Component: [Bindable] public var aListOfData:ArrayCollection; private function sendData():void { -> runs when you click submit in titlewindow var compilation:Obect = new Object; compilation.setting1 = "something in component"; aListOfData.addItem(compilation); (or setItemAt, etc) } Main Application looks like this: [Bindable] private var aListofData:ArrayCollection; private function openComponent():void { -> runs when you click open window in the main app var openingWindow....blah blah, opening the TitleWindow; openingWindow.aListOfData = aListOfData; } OK - so those variable names are random thoughts off the top of my head, bu you get the picture. From what I understand, this doesn't follow the idea behind "loosely coupled components," but is there anything really "wrong" with this methodology? It seems to work very well in my case. I can even have a window within a window, all passing variables between windows, all the way down to the main app quite easily, and so far its been a breeze to setup. Thoughts anyone? If I continue down this path, where will I start to run into problems? - Chris --- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> , "Roman Protsiuk" <[EMAIL PROTECTED]> wrote: > > Hi. > > Why don't your pop up dispatch some event (e.g. "submitData") and you listen > to it? > > R. > > On 12/5/06, qnotemedia <[EMAIL PROTECTED]> wrote: > > > > OK - so I'm using the generic TileWindow example found on the > > Component Explorer. It basically shows you how to build something > > where: > > 1) User clicks a button, Window pops up. > > 2) User types into a text box in the window, clicks Submit. > > 3) Text typed in appears in the main app. > > > > http://examples.adobe.com/flex2/inproduct/sdk/explorer/explorer.html <http://examples.adobe.com/flex2/inproduct/sdk/explorer/explorer.html> > > > > But, I'm having a little difficulty understanding the assignment of > > the returned data. i.e.: > > > > login.loginName=returnedName; > > > > ...where login is the instance of the TitleWindow, loginName is a > > public Text variable inside the component, and returnedName is a text > > box in the main app. > > > > My confusion comes up when I try to edit this so that: > > 1) App has a combobox. Dataprovider for the combobox is an > > ArrayCollection of data: "data" and "label." User clicks a button, > > TitleWindow pops up. > > 2) User types into a text box in the window, clicks Submit. > > 3) The text is a passed as a label, along with a generated ID > > (generated in the component) and is added to the combobox's > > dataprovider. > > > > The problem appears to be that there is no handler of the Submit > > button click on the main application. Obviously, I would add to a > > datasource and return an ID from that, but I can't even get this to > > work manually (i.e. for testing purposes, setting a static data and > > label). > > > > Just trying to keep this as simple as possible. Seems to me that if > > I can pass a string of text, I should also be able to pass an Object > > that is added to a dataProvider in the main app? Right? > > > > Help! > > - Chris > > > > > > >