I put some code in frame 1 of timeline (eg. a command to increment ClipA.x of 10)
I supposed that every time the animation of ClipA cycle the command would be executed (–> +10, --> +10 …)
It does not work. the code is executed just once. Do you know why?
Hey @blurredPixels, this depends on the layout of your frames, and the script you placed the code in. Mind sending an example project or your project to explain the issue?
sure! here it is
timeline_code.wick (1.5 KB)
in this project on frame 1 there is a code that increment quad clip x position
as the animation cycle through 5 frames I expected the script to be executed every time the playhead shows frame 1.
Actually I think it should be the same even with a 1 frame animation (it should keep cycling on the single frame)
Hi @blurredPixels, I know you already reached out to Luxapodular, I just wanted to offer a suggestion.
To me, it seems the reason your code is only executing once is this:
You have a single frame that is stretched for 5 frames. When you put code into a stretched frame like this, it’s kind of like saying “I want the same thing to happen on all the frames that this is stretched over.” The code will not restart or increment when looping through the same frame - you need to have left that frame and then returned to it for that to happen.
Here’s an example of what I mean - I’ve used this kind of stretched frame to add background music to games. Here’s how that would look:
When I first start on the “menu” frame, some background music starts playing, and it will continue to play during all of these frames. If I go to the “game” frame, and then return to the “menu” frame, it doesn’t restart the music or start playing it again. It has only been specified to execute once for all of these frames (although if you specified the music to loop, it would have a continuous effect for the whole game). I’ve basically just said, “I want the same code to apply to all of these frames, and I don’t want it to change”.
For some alternative suggestions for your project, I thought of a couple. If you moved your code to a single frame on a different layer from your stretched frame, that would make the code increment. (Because you would be leaving that frame and then returning to it, causing the code to start again).
incrementMove1.wick (1.6 KB)
Another would be to move the code to an update script that checks when the project is on the first frame:
incrementMove2.wick (1.6 KB)
ty bluecake
as always your answers are very detailed and useful !
It was a flash oriented kind of reasoning. Now I see how it works
Thanks, I’m glad it helped…sometimes I wonder if my answers are too long But if they are helpful, I guess that’s okay