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

Launch animate cc movie when scroll

Community Beginner ,
Nov 29, 2017 Nov 29, 2017

Hey guys,

I have an animate cc (so a canvas) movie in a page but I have a lot of content before and the animation doesn't show directly in the viewport, we must scroll to see it. I would like my animation to launch ONLY when I scrool and when it appears on the page.

Can someone help me please? I could do it in the past with Edge animate but never found any documentation about that script in animate cc..

Thanks a lot !

1.9K
Translate
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

correct answers 1 Correct answer

Community Expert , Nov 29, 2017 Nov 29, 2017

var px_to_mc = 100;

var scroll_function = scrollF.bind(this);

window.addEventListener("scroll", scroll_function);

function scrollF(){

var scrollTop = window.pageYOffset || (document.documentElement || document.body.parentNode || document.body).scrollTop;

if(scrollTop>px_to_mc){

window.removeEventListener("scroll", scroll_function);

this.mc.play();

}

}

Translate
Community Expert ,
Nov 29, 2017 Nov 29, 2017

var px_to_mc = 100;

var scroll_function = scrollF.bind(this);

window.addEventListener("scroll", scroll_function);

function scrollF(){

var scrollTop = window.pageYOffset || (document.documentElement || document.body.parentNode || document.body).scrollTop;

if(scrollTop>px_to_mc){

window.removeEventListener("scroll", scroll_function);

this.mc.play();

}

}

Translate
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
Community Beginner ,
Dec 02, 2017 Dec 02, 2017

Thanks for the answer but I'm sorry.. I don't know how to use it.. do I have to add it in Animate CC in the action panel or in a separated js code in my page ?

thank you !

Translate
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
Community Expert ,
Dec 02, 2017 Dec 02, 2017

the actions panel.

Translate
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
Community Beginner ,
Dec 02, 2017 Dec 02, 2017

so I guess this.mc.play(); -> mc is the movieclip that has to launch ?

Translate
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
Community Expert ,
Dec 02, 2017 Dec 02, 2017

yes, that's the place-holder for the movieclip that you want to play when the page is scrolled.  px_to_mc is the number of pixels the page must scroll to bring that movieclip into the viewport.

Translate
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
Community Beginner ,
Dec 02, 2017 Dec 02, 2017

Sorry I don't understand.. it was so easy in Edge Animate and I'm new in Animate CC

Can you provide me a working example please?

thank you..

Translate
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
Community Expert ,
Dec 02, 2017 Dec 02, 2017
Translate
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
Community Beginner ,
Dec 03, 2017 Dec 03, 2017

Thank you a lot !!! I'm going to try this example !!!

Have a nice day !

Chris

Translate
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
Community Expert ,
Dec 03, 2017 Dec 03, 2017

you're welcome.

Translate
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
New Here ,
Dec 04, 2019 Dec 04, 2019
LATEST

hi kglad, i want to understand the same, but your above examples files are not availabe on mentioned link, can please provide me the same. thanks in advance

Translate
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
Community Beginner ,
Apr 07, 2018 Apr 07, 2018

Hello Chris,

Do you have the same code to launch animation when visibility is "true" ?

It would be so useful as i work with iframe for my animations

Thks a lot

Translate
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
Community Beginner ,
Apr 11, 2018 Apr 11, 2018

still didn't manage to make the example work..

for the moment I focuse on trying to load external content into an animate cc comp just like it was possible in flash many years ago via actionscript (loadmovie) but not anymore with the new animate cc.. it's really a pain

Translate
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