• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

setTimeout Not Working in iframe with Global Variable

Contributor ,
Aug 28, 2021 Aug 28, 2021

Copy link to clipboard

Copied

I am working on an animation piece and was using setTimeout to pause the playhead. 

 

I am using a global variable (at least I think I am). Where in the main timeline in the first frame I have:

window.wordpause=300;

Then in a MovieClip that shows up on the second frame of the main timeline I have this code (in the movieClip) to pause the playhead for the value in the "wordpause" variable. 

this.stop();
setTimeout(this.play.bind(this), parent.wordpause);

This works fine when viewing the HTML file via a direct path to its page. But when I place this inside an iframe, it appears that variable is not working, there is no pause at all between frames so the piece runs super fast.

 

I have tried to find a tutorial for using global variables (assigning them and using them), but have not come up with anything. I saw one suggestion of using 

document.wordpause=300;

But that does not work. Any help with this issue would be appreciated.

 

I know my client will be tweaking the speed of things and rather than having to fiddle with everything via the timeline by adding or subtracting frames, I thought I could simple change the speed with a variable. 

Views

357

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Aug 28, 2021 Aug 28, 2021

Copy link to clipboard

Copied

I believe I figured it out. On the maintimeline I changed this:

window.wordpause=300;

to this

this.wordpause=300;

and in the Movie Clip I changed this:

this.stop();
setTimeout(this.play.bind(this), parent.wordpause);

to this:

this.stop();
setTimeout(this.play.bind(this), exportRoot.wordpause);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Aug 28, 2021 Aug 28, 2021

Copy link to clipboard

Copied

It seems that the variable's values are working now within a iframe. I'm guessing that the "parent.wordpause" was trying to get the value of a variable in the page that has the iframe code vs the page being shown via the iframe.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 28, 2021 Aug 28, 2021

Copy link to clipboard

Copied

LATEST

There is no reason to be using a variable that's global to the entire browser page if you're only going to be accessing it from within Animate. Just use the global Animate root object exportRoot. And don't use "parent" to access global variables. They're global. Trying to access them relatively entirely misses the point.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines