> On 01.05.2006 18:36, Christopher Nelson wrote:
> > ---
> > // Setup some helpers for the particleFountain object.
> > particleFountain.Stop = function()
> > {
> > var stopCmd = 0;
> > particleFountain.onEvent(stopCmd);
> > }
> >
> > particleFountain.Start = function()
> > {
> > var startCmd = 1;
> > particleFountain.onEvent(startCmd);
> > }
> > ---
>
> What if I want, say, two particle fountains, with identical
> methods etc.
> but affecting e.g. two different fountains visible on screen?
You would then have two buttons. In that case you would do something
much like this:
function stopFountain(myFountain)
{
return function()
{
var stopCmd = 0;
myFountain.onEvent(stopCmd);
}
}
<widget type="Button">
<setup>widget.Resize(10,0);</setup>
<event name="onMouseClick" action="stopFountain(fountain1);" />
</widget>
<widget type="Button">
<setup>widget.Resize(10,0);</setup>
<event name="onMouseClick" action="stopFountain(fountain2);" />
</widget>
On the other hand, you could simply have the action call the proper
fountain. You could also do this:
particleFountain.Stop = function(lots,of,parameters,and,stuff)
{
var stopCmd = 0;
particleFountain.onEvent(stopCmd,lots,of,parameters,and,stuff);
}
Not a problem. All of these options work with the system as currently
implemented. IMHO, if you are suggesting object orientation it is the
height of silliness to control two different fountains using the same
instance of the same object.
> > Being able to accept and post more sophisticated objects
> would require
> > your app to be more tightly bound to the JS api. In that case, you
> > will not be using AWS2's simple interface.
> Or you could make AWS2's interface powerful enough to allow
> more sophisticated objects, AWS2 would provide the necessary
> glue then.
This statement is a null op. There is no good reason for AWS2 to
duplicate the functionality present in the JS library. If you wish to
create more sophisticated native/script interaction, there's no good
reason not to plug into the JS library. Some might claim that AWS2
might be rewritten to use a different scripting library in the future.
While that is vaguely possible, it would not be AWS2. The vast majority
of the plugin is tied to JS very closely, not to mention the fact that
all the widgets are written in JS.
More sophisticated interaction above and beyond simple properties (ie.
Function properties, properties which are also objects, etc.) require
the ability to deal with JS library objects, and would thus require
"pollution" of the AWS2 public interface.
> Any case where you want to have two distinct objects of the
> same "type"?
Then use multiple objects of the same "type." There is nothing
prohibiting this. Nor is there any prohibition against having multiple
arguments in the callback. In fact, you automatically have a variadic
function prototype for the event notification. The notification object
provides a way to find out how many arguments have actually been passed.
> Also, using static functions as callbacks encourages bad coding style.
> Example: Your very own code where you need to access the "application"
> object by using a global static variable. This is just plain
> bad style.
This is your opinion. The app is one and only one object. Therefore,
it is completely appropriate for it to be a singleton provided by an
accessor. I personally feel that polluting the app with initialization
objects is tedious and ugly, especially when moved into the functor
world. Granted, there are simple ways around this, but I don't like
them. Again, it is a matter of asthetics.
> Using real C++ methods avoid that; plus, you have the option
> of making your "script object" support less limited in the
> future (say if you get the idea that providing a away to
> return new objects to JS via function results would be nice).
That is already possible via a different mechanism. I could technically
provide a way to use return values, but they would still be limited to
integers, doubles, and strings. I don't see why a return value is more
useful than the ability to set a property. These are notification
objects, after all.
-={C}=-
-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0709&bid&3057&dat1642
_______________________________________________
Crystal-main mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/crystal-main
Unsubscribe: mailto:[EMAIL PROTECTED]