Sie sind nicht angemeldet.

1

Dienstag, 10. November 2020, 17:52

args not working for loadscene

I'm trying to pass variables to an action. But when using a variable for the loadscene I just get "null" as error.

This is the action:

Quellcode

1
<action name="startVideo" scope="local" args="var1,var2">set(layer[video].visible,true);set(layer[video].onvideoplay, eventstarter(); loadscene(get(var2), null, MERGE|KEEPPLUGINS));layer[video].playvideo(get(var1));</action>



And this is the calling:

Quellcode

1
onclick="startVideo(pano-images/test.mp4, Pano_01);"



When using trace the variable is correctly printed in the console, and the first variable for the video url is also working. Just not the loadscene.

2

Dienstag, 10. November 2020, 21:16

your var2 is not defined when your onvideoplay is called
you need to write its content into the onvideoplay call :

calc(layer[video].onvideoplay, 'eventstarter();loadscene(' + var2 + ', null, MERGE|KEEPPLUGINS)');

Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »indexofrefraction« (10. November 2020, 21:31)


3

Mittwoch, 11. November 2020, 11:53

Thx for the explanation.
I dont really get why its this way, but as long as it works.

4

Mittwoch, 11. November 2020, 13:18

inside startVideo() you create a new action layer[video].onvideoplay
which is called later, when the video starts to play

onvideoplay() is not called with your arguments var1 and var2 from startVideo()
so var2 is undefined / null at that point

so in startVideo you create onvideoplay with the contents of var2 not with "var2"
you can add trace(layer[video].onvideoplay); atfter creating it to check how it works

Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »indexofrefraction« (11. November 2020, 21:51)