Making the delegate a singleton solved the problem.  Thank you very 
much for the insight.

- TH


--- In [email protected], "JesterXL" <[EMAIL PROTECTED]> wrote:
>
> Hrm... good point.  Typicaly this:
> 
> function test()
> {
>    a = new String();
> }
> 
> test();
> test();
> 
> Will cause the first created a to be destroyed & replaced with a 
new one.  I 
> reckon the old one is marked for garbage collection.
> 
> However, "think" is dangerous.  I can see how for 99% of the use 
cases you'd 
> want a Delegate to be a singleton to be utilized from a command, 
so that 
> makes perfect sense; good idea!
> 
> 
> 
> ----- Original Message ----- 
> From: "Tim Hoff" <[EMAIL PROTECTED]>
> To: <[email protected]>
> Sent: Monday, April 17, 2006 1:23 PM
> Subject: [flexcoders] Re: Cairngorm2 Commands and Singletons
> 
> 
> That's what I thought Jester.  So the problem is not with the
> commands but rather with the delegates.  The samples provided
> similar code to this:
> 
>    var delegate : GetAuthorsDelegate = new GetAuthorsDelegate();
> 
> I'll make these singletons and see if that clears up the problem.
> 
> Thanks,
> 
> - TH
> 
> 
> --- In [email protected], "JesterXL" <jesterxl@> wrote:
> >
> > Cairngorm at start up creates a single instance of a command 
class
> at start
> > up.
> >
> > ARP, another framework like Cairngorm, creates an instance of a
> command when
> > it's called.
> >
> > Multiple calls to a Cairngorm command via EventBroacaster use the
> same
> > Command instance.
> >
> > Multiple calls to an ARP command via EventBroacaster use a new
> Command
> > instance.
> >
> > While I've been told Commands should be stateless, I disagree.
> Since you
> > can't block in Flash Player and everything is asyncronous, I 
think
> Commands
> > should have some form of state, even if this state is internal,
> and is
> > merely in the form of callback functions that it only uses for
> itself (aka
> > private).
> >
> > That said, Cairngorm's low-level design clearly believes and
> encourages
> > stateless Commands since only 1 instance of a Command class every
> exists.
> >
> > Cairngorm keeps a reference to the Command class instances, so
> they don't
> > really ever go out of scope because they are kept internally in
> the commands
> > array.
> >
> > I know that's not a solution, just information, but figured
> important
> > nonetheless.
> >
> > ----- Original Message ----- 
> > From: "Tim Hoff" <TimHoff@>
> > To: <[email protected]>
> > Sent: Monday, April 17, 2006 12:46 PM
> > Subject: [flexcoders] Cairngorm2 Commands and Singletons
> >
> >
> > Apparently, there has been much discussion concerning singletons
> > here already, but the search feature of this site doesn't seem to
> > ever return complete results.  Coming from a .NET background, 
I've
> > had to change a lot my thinking in regards to objects. This is a
> > good thing.  However, in .NET (VB.NET, C#.NET Java.NET) when an
> > object is instantiated, let's say a class in this case, as soon 
as
> > the object goes out of scope, it is automatically disposed of by
> the
> > garbageCollector.  This doesn't seem to be the case in AS3.  I've
> > patterned an application on the Cairngorm samples that have been
> > provided so far.  The samples are great and I really appreciate
> > them, but none of them make multiple calls to the back-end.  
Using
> > the code provided, if I execute multiple search commands (let's 
say
> > getAuthors), each one of the command instances, along with the
> > associated event listeners and objects, still exist after the
> result
> > or fault is returned.  Thus, when an error is displayed
> > like: "Sorry, no authors found.", since all of the
> > commands/delegates are still listening to the data service, a
> > separate alert box appears for each instance of the command.  
Three
> > calls, three alert boxes.
> >
> > I'm not sure if I should make the commands and delegates
> singletons,
> > or manually dispose (delete _oSingleton) of the instances.  Since
> > the application is Cairngorm based, I don't want to stray too far
> > from best practices.  I was just wondering if anyone else had
> > experienced this problem and if there were some links or advice
> that
> > could be offered?  I also want to say that I think that the Adobe
> > team is doing a great job.  I can't wait for the release of 
Flex2.
> > It's going to turn a lot of heads.
> >
> > Many thanks,
> > Tim Hoff
> >
> > P.S.  It would be nice to have something like the following:
> >
> > public singleton class myClass {}
> >
> >
> >
> >
> >
> >
> >
> >
> > --
> > 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
> >
> 
> 
> 
> 
> 
> 
> 
> --
> 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
>







--
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/

<*> 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