use the add command

  • Hi,

    The code above does not work... *sad*
    It seems that the add() action work well but the variable dest into set(plugin[button].y,dest); seems to not be "passed" correctly. *confused*

    Code
    add(dest,get(plugin[button].y),10);
    trace(dest);
    set(plugin[button].y,dest);

    I do not know why... Sorry... *sad*

    Somebody knows the correct way to "pass a variable" as value to a set() action?

    Salut.

  • Hi,

    Really strange things... *attention*

    After many tries, I reach these conclusions:

    • It seems that the add(dest,get(plugin[button].y),10); action works well.
    • Doing trace(dest); it gives back the correct value.
    • The set(plugin[button].y,dest); does not do the job correctly. It seems that it set the "y" value to 0, null or NaN....
    • But, doing trace(get(plugin[button].y)); it gives back the correct value. *attention* *blink*

    So, I really do not understand what it is happening here *blink* *wacko* *confused* ... If some one can explain it will be very appreciated. *thumbup*

    You can try it using this code:

    Salut.

    Einmal editiert, zuletzt von michel (23. September 2009 um 07:50)

  • Hi nelk,

    I get it... *tongue* The set(plugin[button].y,dest); must be set(plugin[button].y,get(dest));
    Doing this way, all works as expected...

    But then I do not understand why, when I use set(plugin[button].y,dest); , trace(get(plugin[button].y)); gives back the correct value. *attention* *blink*

    Salut.

  • But then I do not understand why, when I use set(plugin[button].y,dest); , trace(get(plugin[button].y)); gives back the correct value. *attention* *blink*

    Hi,

    trace() works a bit tricky

    trace looks up the given text if there is a variable with this name and then traces the content of it,
    and only if there is no variable it traces the given text,

    e.g. it will be resolved in this way:
    1. trace(get(plugin[button].y));
    2. trace(dest);
    3. trace(>>value of dest<<);

    best regards,
    Klaus

  • Hi nelk,

    dest is only a name for the variable ... it can be anything else you like to name your variable. *wink*

    Code
    <action name="move">
        add(new_variable,get(plugin[pluginToMove].y),10);
        trace(new_variable);
        set(plugin[pluginToMove].y,get(new_variable));
        trace(get(plugin[pluginToMove].y));
    </action>

    Salut.

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!