Ah...I understand what you are doing.

Is this the best way though?  I can see how it's EASY.

But putting a reference to the details canvas w/in the master canvas 
tightly couples them together.  Some might say they that a master and
detail should be tightly coupled but I go for a loosely coupled
approach...which the LSO does.

Do you have a more loosely coupled approach?  Should I be using custom
events to achieve this?


--- In [email protected], "Tracy Spratt" <[EMAIL PROTECTED]> wrote:
>
> Honestly, using LSO for this is nuts. If I am understanding fully.
> 
>  
> 
> Say the value you want is a record id, and you can select it in a
> datagrid or list component in the main app, and need to pass it into the
> component.
> 
>  
> 
> In your component, create a public property.  You can implement it as a
> public var or with a setter function.  If you want the change of the
> value to initiate some action, like call a data service, use a setter. 
> 
>  
> 
> When you instantiate the component, pass in the value you want using
> binding:
> 
> <myCodeBehindCanvasMainApp .....
> 
>   ...
> 
> <mx:Script...
> 
>    [Bindable]var _sRecordId:String;
> 
>  
> 
>   private function onSelectRecord(oEvent:Event)...
> 
>      _sRecordId = oEvent.target.selectItem.ID;
> 
>  
> 
> ...
> 
>   <myCodeBehindCanvasCOMPONENT recordId="{_sRecordId }"
> 
>  
> 
> ...
> 
>  
> 
> In myCodeBehindCanvasCOMPONENT:
> 
> ...
> 
>   /** Setter function */
> 
>   public function set recordId(s:String):void {
> 
>    myDataService.send({recid:s})
> 
> ...
> 
>  
> 
> Tracy
> 
>  
> 
> ________________________________
> 
> From: [email protected] [mailto:[EMAIL PROTECTED] On
> Behalf Of stlum9495
> Sent: Friday, October 05, 2007 7:46 PM
> To: [email protected]
> Subject: [flexcoders] Re: Passing ID from master to detail
> 
>  
> 
> Hi Tracy,
> 
> Thanks for replying.
> 
> Yes, my mxml are in different files. I should prob have said this
> earlier -- my canvases are done using the code behind pattern, so I
> have a mxml for each canvas, and behind it is an .as that extends
> Canvas.
> 
> Perhaps I should have specified more. For this example, say there is
> a datagrid with a bunch of user information. when you click on a row
> / user, a new canvas is selected in the viewstack w/ more user
> detailed information.
> 
> Like I said, currently I'm using a Local Shared Obj...what is your
> recommended way?
> 
> Thanks
> 
> --- In [email protected] <mailto:flexcoders%40yahoogroups.com>
> , "Tracy Spratt" <tspratt@> wrote:
> >
> > There are much simpler ways.
> > 
> > 
> > 
> > If your two canvases are in the same mxml file(class) then they share
> > the the same scope and you can bind or access values directly. If they
> > are implemented in different mxml files, then it is a tiny bit more
> > complicated.
> > 
> > 
> > 
> > Same scope
> > 
> > Declare an id in any mx tag you want to be able to access. Then you
> can
> > access values by doing something like this:
> > 
> > in AS:
> > 
> > myText1.text = myText2.text; 
> > 
> > myText1.text = myComboBox.selectedItem.myProperty
> > 
> > 
> > 
> > Binding In mxml:
> > 
> > <mx:Text text="{myText2.text}" ...
> > 
> > <mx:Text text="{myComboBox.selectedItem.myProperty}" ...
> > 
> > 
> > 
> > If myText1 and myText2 are in different scope(different mxml files),
> > post, and I will explain how to do that.
> > 
> > 
> > 
> > Tracy
> > 
> > 
> > 
> > 
> > 
> > ________________________________
> > 
> > From: [email protected] <mailto:flexcoders%40yahoogroups.com>
> [mailto:[email protected] <mailto:flexcoders%40yahoogroups.com>
> ] On
> > Behalf Of stlum9495
> > Sent: Friday, October 05, 2007 10:21 AM
> > To: [email protected] <mailto:flexcoders%40yahoogroups.com> 
> > Subject: [flexcoders] Passing ID from master to detail
> > 
> > 
> > 
> > Hi,
> > 
> > I've been programming for awhile, but am new to Flex and was wondering
> > what the best way of passing values from screen to screen is.
> > 
> > Currently, I have two canvases which have a master detail
> > relationship. When I click on a button in the master canvas, I want
> > to pass the record id to the detail canvas so that the detail canvas
> > can query the server for the details data. simple master detail.
> > 
> > To code this in flex, what I did was when the button was clicked on
> > the master, I saved the record id into a Local Shared Object, and when
> > my Detail canvas appears, I grab the id from said Local Shared Object
> > and make my server side request.
> > 
> > This works fine, but I was wondering -- is this the Best Practice way?
> > I haven't seen much by way of design patterns etc for flex
> > pages(I've seen the AS book) so was wondering if I should be doing
> > this differently.
> > 
> > Thanks
> >
>


Reply via email to