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

SWF and system events/variables

New Here ,
Aug 17, 2018 Aug 17, 2018

Hi--

Just trying to save the user's slide number during a movie and reload it if the user leaves and returns. My CP files run in an iframe on a parent page with some JS functions on the parent that communicates with our database.

So, when the page loads, I load the user's last viewed slide number and as the user changes changes slides, I save it with some calls to the JavaScript. This is the code on the first slide with On Enter:

var jump=parent.getSlide();

if (jump>0) {

    window.cpAPIInterface.setVariableValue('cpCmndGotoSlide', jump);

}

window.cpAPIEventEmitter.addEventListener("CPAPI_SLIDEENTER",function() {

     parent.setSlide(cpInfoCurrentSlide);

});

This works perfectly when publishing as HTML, but when publishing as SWF, only the first function gets called. I can change the frame number in my database and my file will read and jump to it when loading. However, when publishing as SWF, the event listener doesn't seem to fire. I've even removed the listener and just added:

parent.setSlide(cpInfoCurrentSlide);

to the script and it does nothing. I've even tried cpInfoCurrentFrame and nothing.

Am I missing something or does this just not work with SWF? I'm using CP 9 and using Internal Server Reporting.

Any help is greatly appreciated.

Thank you!

280
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
People's Champ ,
Aug 20, 2018 Aug 20, 2018

More than likely the cpAPIInterface doesn't exit yet when you are trying to add the listener.

You should first add a listener for the moduleReadyEvent

window.addEventListener("noduleReadyEvent", function()

{

//YOUR LISTENER HERE

}

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 ,
Aug 20, 2018 Aug 20, 2018

Thank you so much for the reply. Unfortunately, it's still not working. Here is my code again for reference:

var jump=parent.getSlide();

if (jump>0) {

    window.cpAPIInterface.setVariableValue('cpCmndGotoSlide', jump);

}

window.addEventListener("moduleReadyEvent", function() {

alert('ready');

    window.cpAPIEventEmitter.addEventListener("CPSlideEnterEvent",function() {

        parent.setSlide(cpInfoCurrentSlide);

    });

});

The first JS call works fine. I'm not even seeing the alert message in the listener. What else could be happening?

EDIT:

Just for fun, I distilled the code to the bare minimum:

alert(cpInfoCurrentSlide);

Nothing still. This is set to run On Enter and it's on the first 3 slides.

Does cpInfoCurrentSlide not work with SWF?

EDIT 2:

Just tried this in the trial version of CP 2017 and it still doesn't work. Back to the drawing board...

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
People's Champ ,
Aug 20, 2018 Aug 20, 2018

You'll need to use window.cpAPIInterface.getVariableValue("cpInfoCurrentSlide")

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 ,
Aug 20, 2018 Aug 20, 2018
LATEST

Success! Thank you.

However, the event listener still isn't firing.

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
Resources
Help resources