How do I call a JS constructor that takes parameters

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How do I call a JS constructor that takes parameters

bowerandy-2
Hi,

I'm playing around with the HTML5 Canvas wrapper library KineticJS in Amber but I can't find a way to call constructor functions that take parameters. For example, How would I reproduce this JS call in Amber:

      var rect = new Kinetic.Rect({
        x: 239,
        y: 75,
        width: 100,
        height: 50,
        fill: 'green',
        stroke: 'black',
        strokeWidth: 4
      });

Best regards

Andy Bower

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: How do I call a JS constructor that takes parameters

bowerandy-2
Replying to my own question, I think I've found it here:

http://forum.world.st/BlockClosure-as-a-JavaScript-constructor-td4162123.html

Now Amber has BlockClosure>>newValue: and #newValue:value: 
#newValue:value:value: 

here's an example: 
new Foo();                // JS version 
Foo new.                  "Amber version" 

new Foo(1,2);             // JS version 
Foo newValue: 1 value: 2. "Amber version" 

Best regards

Andy Bower

On Friday, January 10, 2014 8:48:07 PM UTC, bowerandy wrote:
Hi,

I'm playing around with the HTML5 Canvas wrapper library KineticJS in Amber but I can't find a way to call constructor functions that take parameters. For example, How would I reproduce this JS call in Amber:

      var rect = new Kinetic.Rect({
        x: 239,
        y: 75,
        width: 100,
        height: 50,
        fill: 'green',
        stroke: 'black',
        strokeWidth: 4
      });

Best regards

Andy Bower

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: How do I call a JS constructor that takes parameters

Manfred Kröhnert
Hello Andy,

On Sat, Jan 11, 2014 at 1:47 AM, bowerandy <[hidden email]> wrote:
Replying to my own question, I think I've found it here:


Now Amber has BlockClosure>>newValue: and #newValue:value: 
#newValue:value:value: 

here's an example: 
new Foo();                // JS version 
Foo new.                  "Amber version" 

new Foo(1,2);             // JS version 
Foo newValue: 1 value: 2. "Amber version" 

Best regards

Andy Bower


thanks for the examples.
I added them to the Amber Recipies collection here:


Best,
Manfred

 
On Friday, January 10, 2014 8:48:07 PM UTC, bowerandy wrote:
Hi,

I'm playing around with the HTML5 Canvas wrapper library KineticJS in Amber but I can't find a way to call constructor functions that take parameters. For example, How would I reproduce this JS call in Amber:

      var rect = new Kinetic.Rect({
        x: 239,
        y: 75,
        width: 100,
        height: 50,
        fill: 'green',
        stroke: 'black',
        strokeWidth: 4
      });

Best regards

Andy Bower

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.