[Solved] How do I get the Behavior parameters into JavaScript?

Hi guys,
I am trying to make a fade behaviour but I can’t use the parameters in the JavaScript code.

To be more specific, how can I access “FadeTime” or “FadeObject” in the JavaScript “snippet”?

Any ideas?

Farid

First your parameters are ok. For param #2 you use Objects type and i see in javascript event you have pass your parameters FadeObject. Everything is great for now.

Now in JSevent you got objects, objects is a list of all instances of the object pass as parameters into the function.

Then you can do

const firstInstanceOfMyObject = objects[0];
firstInstanceOfMyObject.setPosition(100,100);

Now for your first parameter #1 FadeTime.

You have to get the value of this parameter like

eventsFunctionContext.getArgument("FadeTime");

I recommend you to read this wiki page about how use javascript event.

You trying to use

GetArgumentAsNumber(“FlashDuration”)
In a JSevent but this is an expression to be use in a classic action or condition, not in JSevent.
Same for

GetArgumentAsString()
And you don’t need to escape the quotes.

1 Like

Note instead of pass the object in the header of the JSevent you can do

eventsFunctionContext.getObjects("myObjectParameter");

Thank you very much Bouh!
Now it works with this code:

//Farid

1 Like