reference inline fs variable

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

reference inline fs variable

Eno
Hi again, for help.

I'm trying to translate js script to amber.
There are js variables need to be referenced.
such as:

linkDemo
<
            var position;
            var target;
            var tween, tweenBack;

            function init() {
            ----
            --- } ;
>

is it possible to call those variables, position, target, tween, tweenBack via amber methods?
( I tried to separate each function to separate inline amber methods but each method can not reference other's variables ).

thanks.


--
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.
Eno
Reply | Threaded
Open this post in threaded view
|

Re: reference inline fs variable

Eno
Hi,
  Trying on myself after figuring more deeply to native js codes.
  I think I could put those variables that are needed to be referenced inside Amber under window namespace.
  That is to say, if I need function "init" to be called by Amber method, I wrapped it as:
       window.init = function init() {
            ----
            --- } ;

then, I called that function in Amber as:
       ( window at: init ) value.

if the js codes are written as:

var Tinycon = {};
Tinycon.setBubble = function(label, colour) {
        label = label || '';
        drawFavicon(label, colour);
        return this;
    };
window.Tinycon = Tinycon;

then I could call the js function setBubble as:

( window at: 'Tinycon' ) setBubble: 12.

Just a think, not sure the robust formal way.



EnoX1於 2013年10月23日星期三UTC+8下午4時32分55秒寫道:
Hi again, for help.

I'm trying to translate js script to amber.
There are js variables need to be referenced.
such as:

linkDemo
<
            var position;
            var target;
            var tween, tweenBack;

            function init() {
            ----
            --- } ;
>

is it possible to call those variables, position, target, tween, tweenBack via amber methods?
( I tried to separate each function to separate inline amber methods but each method can not reference other's variables ).

thanks.


--
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: reference inline fs variable

Herby Vojčík
You don't need to use window, you see all globals directly.

Just define function init() {...} and var Tinycon = {...} in global space
(load their <script>s before amber) and then you can do:

init value

or

Tinycon setBubble: 12

Herby

EnoX1 wrote:

> Hi,
> Trying on myself after figuring more deeply to native js codes.
> I think I could put those variables that are needed to be referenced
> inside Amber under window namespace.
> That is to say, if I need function "init" to be called by Amber
> method, I wrapped it as:
> window.init = function init() {
> ----
> --- } ;
>
> then, I called that function in Amber as:
> ( window at: init ) value.
>
> if the js codes are written as:
>
> var Tinycon = {};
> Tinycon.setBubble = function(label, colour) {
> label = label || '';
> drawFavicon(label, colour);
> return this;
> };
> window.Tinycon = Tinycon;
>
> then I could call the js function setBubble as:
>
> ( window at: 'Tinycon' ) setBubble: 12.
>
> Just a think, not sure the r
obust formal way.

>
>
>
> EnoX1於 2013年10月23日星期三UTC+8下午4時32分55秒寫道:
>
>     Hi again, for help.
>
>     I'm trying to translate js script to amber.
>     There are js variables need to be referenced.
>     such as:
>
>     linkDemo
>     <
>     var position;
>     var target;
>     var tween, tweenBack;
>
>     function init() {
>     ----
>     --- } ;
>     >
>
>     is it possible to call those variables, position, target, tween,
>     tweenBack via amber methods?
>     ( I tried to separate each function to separate inline amber
>     methods but each method can not reference other's variables ).
>
>     thanks.
>
>
> --
> 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.
Reply | Threaded
Open this post in threaded view
|

Re: reference inline fs variable

Manfred Kröhnert
In reply to this post by Eno
Hi, 

sorry for the late response but your message somehow slipped under my radar.
I think you should not try to recreate the JS code one be one in Amber through inline JS.

To me the following variables look more like instance variables to me:
  var position;
  var target;
  var tween, tweenBack;
If this is the case then they should also be treated as such.
Then they will be available in any method you call on your object.

Also, your Tinycon construct looks like it should be a separate Amber class.

Best,
Manfred





On Tue, Oct 29, 2013 at 4:21 PM, EnoX1 <[hidden email]> wrote:
Hi,
  Trying on myself after figuring more deeply to native js codes.
  I think I could put those variables that are needed to be referenced inside Amber under window namespace.
  That is to say, if I need function "init" to be called by Amber method, I wrapped it as:
       window.init = function init() {
            ----
            --- } ;

then, I called that function in Amber as:
       ( window at: init ) value.

if the js codes are written as:

var Tinycon = {};
Tinycon.setBubble = function(label, colour) {
        label = label || '';
        drawFavicon(label, colour);
        return this;
    };
window.Tinycon = Tinycon;

then I could call the js function setBubble as:

( window at: 'Tinycon' ) setBubble: 12.

Just a think, not sure the robust formal way.



EnoX1於 2013年10月23日星期三UTC+8下午4時32分55秒寫道:
Hi again, for help.

I'm trying to translate js script to amber.
There are js variables need to be referenced.
such as:

linkDemo
<
            var position;
            var target;
            var tween, tweenBack;

            function init() {
            ----
            --- } ;
>

is it possible to call those variables, position, target, tween, tweenBack via amber methods?
( I tried to separate each function to separate inline amber methods but each method can not reference other's variables ).

thanks.


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