SnapSVG-Animator icon indicating copy to clipboard operation
SnapSVG-Animator copied to clipboard

Continuous movie clip frame script execution.

Open UserNumberTwo opened this issue 9 years ago • 8 comments

MovieClip frame scripts get executed on every subsequent frame during playback until the last frame is reached. In addition to this, calling stop() on a particular frame doesn't stop the execution of frame scripts.

It seems that the interval function of the SVGAnim class is responsible for this. Calling stop() on the instance of SVGAnim does stop the interval preventing any further frame script execution however it seems to do it for the entire animation.

UserNumberTwo avatar Jul 20 '16 14:07 UserNumberTwo

I have a fix for this on dev if you replace the published SnapSVGAnimator.js file in your project with the one in dev it should fix the issue.

cjgammon avatar Oct 10 '16 15:10 cjgammon

I tried this, but it doesn't seem to work. Code is still executing on every frame ... I am using the devs SnapSVGAnimator.min.js though

martenzander avatar Nov 04 '16 08:11 martenzander

@SlimMarten can you post the output files so I can take a look?

cjgammon avatar Nov 04 '16 16:11 cjgammon

@cjgammon What I discovered was that scripts added on a particular frame would persist and be executed until another frame containing a script was encountered. Even a single space character on a subsequent frame would clear the scripts and prevent them from being executed. I solved it by adding this._scripts = {} to the step_6_exitFrame method although I'm not sure if this solution would have any adverse side effects.

UserNumberTwo avatar Nov 04 '16 16:11 UserNumberTwo

@cjgammon actually you can clone my repo (https://github.com/SlimMarten/svg_animations). If you go to /src/animations/an/ you can take a look at the app-dev.fla

martenzander avatar Nov 05 '16 14:11 martenzander

@cjgammon I added a console.log on the first frame on the main timeline for reference.

martenzander avatar Nov 05 '16 14:11 martenzander

Thanks @SlimMarten I'll take a look into this when I get some time.

Based on what @UserNumberTwo said it seems that frameScripts are not getting removed properly so either the event isn't getting triggered in the JSON or I need to manually remove them similar to how he is. I'll have to investigate more, but the temporary fix he posted shouldn't break anything.

cjgammon avatar Nov 08 '16 20:11 cjgammon

I think this problem is a little bigger. I also actually feel the problem is so important that it should either be addressed immediately or at least the docs should reflect there is an important bug. Anyone new to the project (like me) likely assumes it works better than it does from the current master branch.

I love the plugin. And for some simple FLAs it will work as-is. But it needs some polish to make it work for everything else.

There is a fundamental problem in "step_1_animTimeline()" in that the "commandList" member var is cleared, but "_scripts" is not. Effectively, the problem is that "framescript" is "prepared" (not executed, just made "ready") at every frame whether the movieclip plays through it or seeks past it (via gotoAndPlay/gotoAndStop). When the target frame is "played", it will execute the "previously prepared framescript", even though it shouldn't.

As an example, if you have framescript on frame 10 that says: console.log('Hi, I'm frame 10!' and at frame 5 you execute: this.gotoAndStop(15) when the playback stops on frame 15, it will execute the framescript from frame 10.

This is NOT fixed using the suggestion from @UserNumberTwo.

To address the issue, I have actually added: this._scripts = {}; immediately after the line: this.commandList = []; in "step_1_animTimeline()".

I believe this will address several of the outstanding "playback-oriented" issues listed in the project. I haven't tested enough to feel confident this is the best solution. But so far it appears to fix the significant problems I was encountering while trying to use the version from the master branch.

acgmultimedia avatar Apr 07 '17 22:04 acgmultimedia