Skip to main content
Legend
June 2, 2023
Question

Canvas executes movieclip frame actions in reverse?

  • June 2, 2023
  • 3 replies
  • 667 views

I thought the Animate change that makes single-frame movieclip code only execute once was bad, but this is so bad I'm half-convinced I must be hallucinating it.

 

Okay, in an HTML5 Canvas document, say you have a movieclip with 5 frames, and on each frame there's "console.log(1);", then "console.log(2);" etc up to "5"  and a "this.stop(); "on the fifth frame. Oh and there's like a red ball or something to make it visible.

 

Now put this movieclip on the root timeline. Say, 10 frames long. Drop an F7 blank keyframe on the last frame so when the main timeline loops the movieclip will be removed from and re-added to the display list.

 

Finally, run it and open the browser's developer console. This is what you'll see:

1

2

3

4

5

4

3

2

1

...over and over for as long as you let it run. Every time the movieclip is re-added to the display list, something in CreateJS is apparently rewinding the movieclip to its first frame and for some insane reason executing every frame action along the way. So the 4, 3, 2, 1 appears all at once, then the 2, 3, 4, 5 trickles out one frame at a time.

 

This is of course absolutely bonkers, and is guaranteed to mess up any multiframe movieclip that's expecting its frame code to execute in a particular order.

 

Anyone know how to work around this? I've tried some contortions with this.gotoAndStop(0) and this.actionsEnabled = true/false, but so far nothing was worked quite right.

This topic has been closed for replies.

3 replies

JoãoCésar17023019
Community Expert
Community Expert
June 2, 2023

Hi.

 

I blame the always confusing autoReset property. If you set its value on the circle to false, it should work as expected.

 

Regards,

JC

kglad
Community Expert
Community Expert
June 2, 2023

@JoãoCésar17023019 

 

that's a strange way to reset by "playing the timeline backwards 1+ times"

kglad
Community Expert
Community Expert
June 2, 2023

i added to your setup and used console.log("m1"), console.log("m2"), ..., console.log("m10"); to the 10 main timeline frames, resp.

 

and things go well except whenever the main timeline goes from its 10th to its 1st frame.

 

m1
1
m2
2
m3
3
m4
4
m5
5
m6
1
m7
2
m8
3
m9
4
m10
m1
3
2
1
5
4
3
2
1
m2
2
m3
3
m4
4
m5
5
m6
1
m7
2
m8
3
m9
4
m10
m1
3
2
1
5
4
3
2
1
m2
2
m3
3

 

also, there's a graphic glitch when the main timeline goes from its 10th to its 1st frame.  everything on-stage in the 5 frame movieclip disappears for ~1/fps seconds during which those unpaired (with the main timeline) movieclip console.log's are displayed.  ie, the code executes in reverse order, but the movieclip timeline doesn't display.

 

looks like a bug report to me..

kglad
Community Expert
Community Expert
June 2, 2023

LOL.  honestly, that has me laughing.

 

ok. i have to go upstairs and confirm that.