Thank you so much Tim for this complete answer. I will use the last to
 stick to the cairgorm recommendations. The technique is simple and clean.

--- In [email protected], "Tim Hoff" <[EMAIL PROTECTED]> wrote:
>
> 
> Ah yes, it gets a little more complicated if the button is in a
> different view than the video.  If you weren't using Cairngorm, I
> would suggest dispatching a custom button event that is listened for in
> the video view.  Then take the snapshot and pass the data.  The idea
> with Cairngorm is to make the views reusable and avoid coupling to other
> views.  The Cairngorm gurus would probably suggest the following
> approach.
> 
> Create a Boolean variable in the ModelLocator called takeSnapshot.  On
> the button click event, dispatch an event-command that updates the
> variable to true.  In the video view use an ObserveValue
>
<http://weblogs.macromedia.com/auhlmann/archives/2006/09/using_binding_s\
> .cfm#more>  tag to listen for the change of the takeSnapshot variable to
> true.  The ObserveValue tag handler function would then take the
> snapshot of the video and dispatch the CairngormEvent (with the
> bitmapData).  I still recommend that you store the bitmapData in the
> ModelLocator and bind the data to the snapshot view.
> 
> By following this approach, the child views don't care about their
> parents and are able to be reused elsewhere.  You could, of course, do
> it the way that you mentioned.  But I think that the way described above
> is more in line with best practices.  I hope that this gives you some
> ideas.
> 
> -TH
> __________________________________
> 
> Tim Hoff
> Cynergy Systems, Inc.
> http://www.cynergysystems.com
> Office <http://www.cynergysystems.comoffice/> : 866-CYNERGY
> 
> --- In [email protected], "gdoucen" <gdoucen@> wrote:
> >
> > Thanks Tim for your answer but my problem come from the way i can
> > gather all the data from differents views in a sole custom event. I
> > agree with you for the rest.
> > My button which trigger the event is in a separate view than the video
> > display i want to take a snapshot. Of course here the problem is
> > simple but i want to generalize it.
> >
> > I think that i was complicating the problem by trying to lead the
> > event to the view that have the videodisplay which then send the custo
> > event to the command.
> >
> > A better way is to simply confide in the parent container of the two
> > view to send itself the custom event to the command cause it have
> > access to the data all the view.
> >
> > <!-- my composite view -->
> > <mx:VBox ...>
> > <mx:Script>
> > <![CDATA[
> >
> > private function handleTakeASnapshot(event:snapshotOrderEvent):void
> > {
> > // Trigger the final event to the command
> > var snapshotVo:SnapshotVO = new SnapshotVO();
> > snapshotVo.image = view1.getSnapshot();
> > var doSnapshotEvent:DoSnapshotEvent = new DoSnapshotEvent(
> > snapshotVo );
> > CairngormEventDispatcher.getInstance().dispatchEvent(
> > doSnapshotEvent );
> > }
> >
> > ]]>
> > </mx:Script>
> > <view:view1 id="view1" />
> > <view:view1 id="view2" myInititialEvent="handleTakeASnapshot(event)"
> />
> > </mx:VBox>
> >
> > It 's correct and clean like that?. If i'm wrong tell me cause i'm a
> > newbie with flex and cairngorm and i want to get the good reflex.
> >
> > Thanks again
> >
> > --- In [email protected], "Tim Hoff" TimHoff@ wrote:
> > >
> > >
> > > Hi,
> > >
> > > Usually, if you're dealing with moving data around a Cairngorm
> > > application, you would create a public variable (or VO) in the
> > > ModelLocator. When you take a snapshot of the video, dispatch a
> > > CairngormEvent that contains the bitmapData (I would do this in the
> > > view's script; not a ViewHelper). In the command, update the
> variable
> > > in the ModelLocator with the data. Now you have the data in a
> centrally
> > > located position. If another view needs access to this data, simply
> > > bind the view's control to the variable in the ModelLocator. As soon
> as
> > > the variable is updated by the command, the second view will
> > > automatically reflect the change.
> > >
> > > This is a simple explanation and may not fit your particular use
> case.
> > > But hopefully it will give you some ideas.
> > >
> > > -TH
> > > __________________________________
> > >
> > > Tim Hoff
> > > Cynergy Systems, Inc.
> > > http://www.cynergysystems.com
> > > Office <http://www.cynergysystems.comOffice> : 866-CYNERGY
> > >
> > >
> > >
> > > --- In [email protected], "gdoucen" <gdoucen@> wrote:
> > > >
> > > > Hi,
> > > >
> > > > My problem is the following.
> > > >
> > > > I use cairngorm framework.
> > > > I have two views. the button in one view triggers an event that
> need
> > > > to get data from the other view. In my case, i take a snapshot of
> the
> > > > video so here i need the bitmap data.
> > > >
> > > > I see two solutions.
> > > >
> > > > First, using viewhelper/viewLocator to get the data from the
> dedicated
> > > > view inside the command class.
> > > >
> > > > I know that viewhelper are mostly not recommended by cairngorm in
> the
> > > > opposite side when it's used to set views from commands but here.
> > > >
> > > > Secondly, use the parent of the two views to transmit the event
> from
> > > > view1 to view2 that send the final event.
> > > >
> > > > The structure could be as below
> > > >
> > > > <!-- my composite view -->
> > > > <mx:VBox ...>
> > > > <mx:Script>
> > > > <![CDATA[
> > > >
> > > > private function handleMyEvent(event:MyCustomEvent):void
> > > > {
> > > > // Trigger the final event after filling up with the data
> > > > view1.sendEvent(event);
> > > > }
> > > >
> > > > ]]>
> > > > </mx:Script>
> > > > <view:view1 id="view1" />
> > > > <view:view1 id="view2" myInititialEvent="handleMyEvent(event)" />
> > > > </mx:VBox>
> > > >
> > > > What is the best way to do that?
> > > >
> > > > If the action was triggered from the view that hold the needed
> > > > informations, i could have passed the data into a custom event
> that
> > > > could be directly read by the command...
> > > >
> > > > I have browse the forum without success to get informations on
> this
> > > > subject. Feel free to redirect me or give me an answer.
> > > >
> > > > Thanks
> > > >
> > >
> >
>





--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/flexcoders/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

Reply via email to