Skip to main content
November 9, 2012
Answered

Custom Widget not calling cpSetValue in Runtime mode

  • November 9, 2012
  • 1 reply
  • 1354 views

Hi,

for some reason , Captivate Runtime is not calling cpSetValue throught the ExternalInterface... so this is really problematic as i need to retreive the movie_handle and the variable_handle.

is anyone already experienced this problem?

Thank you!

E.

This topic has been closed for replies.
Correct answer Widget King

Hi, thank you for helping me.

So whats happend here is based on the documentation and other widget example, captivate at runtime is supposed to call cpSetValue using the ExternalInterface Call.

The problem is, not callBack is been called in runtime... Work well in Edit and Stage Mode thought.

if(ExternalInterface.available == true)

{

          /*

          Todo : Register all the ExternalInterface functions

          */

          ExternalInterface.addCallback( "isStatic" , isStatic );

          ExternalInterface.addCallback( "getInspectorParameters" , getInspectorParameters );

          ExternalInterface.addCallback( "setInspectorParameters" , setInspectorParameters );

          ExternalInterface.addCallback( "setParameters" , setParameters );

          ExternalInterface.addCallback( "cpSetValue" , cpSetValue );

          ExternalInterface.addCallback( "getEditModeWidth", getEditModeWidth);

          ExternalInterface.addCallback( "getEditModeHeight", getEditModeHeight);

          ExternalInterface.addCallback( "IsReadyForSnapShot", IsReadyForSnapShot);

          ExternalInterface.addCallback( "getListOfUsedInternalResources", getListOfUsedInternalResources);

          ExternalInterface.addCallback( "getListOfUsedExternalResources", getListOfUsedExternalResources);

          ExternalInterface.addCallback( "SetExternalResources", SetExternalResources);

          ExternalInterface.addCallback( "SetInternalResources", SetInternalResources);

          ExternalInterface.addCallback( "GetWidgetAPIVersion", GetWidgetAPIVersion);

          ExternalInterface.addCallback( "SetStageModeSize", SetStageModeSize);

          ExternalInterface.addCallback( "SetCaptivateVersion", SetCaptivateVersion);

          ExternalInterface.addCallback( "SetLanguage", SetLanguage);

}

i have my functions defined properly and as stated previously its working in Edit and Stage Mode.

Thank you!

E.


For Edit and Stage mode cpSetValue is called by the external interface. However at runtime the widget swf is pulled inside the Captivate SWF. Because the Captivate runtime is a SWF as well, it doesn't need to use External Interface to call cpSetValue. So instead, it just calls cpSetValue directly like you'd call any other function.

This is why I was asking if you've put this code in an ActionScript class. In that case, if you made cpSetValue private, then Captivate would not be able to call that function because it's against the rules of ActionScript.

Then again, the easiest solution to this is to build your widget with WidgetFactory. It's an API that takes care of all this background stuff for you. You would never have this problem if you were working with WidgetFactory. Check out the Widget King blog to learn how it works.

Tristan,

1 reply

Legend
November 10, 2012

Try cpEISetValue

The "EI" stands for ExternalInterface.

I'm not 100% what you're tyring to do... if you could post some code, that would be great.

Jim Leichliter

Widget King
Inspiring
November 10, 2012

Have you placed the Widget Template in a class by any chance?

If so, make sure cpSetValue is a public function.

Tristan,

November 12, 2012

Hi, thank you for helping me.

So whats happend here is based on the documentation and other widget example, captivate at runtime is supposed to call cpSetValue using the ExternalInterface Call.

The problem is, not callBack is been called in runtime... Work well in Edit and Stage Mode thought.

if(ExternalInterface.available == true)

{

          /*

          Todo : Register all the ExternalInterface functions

          */

          ExternalInterface.addCallback( "isStatic" , isStatic );

          ExternalInterface.addCallback( "getInspectorParameters" , getInspectorParameters );

          ExternalInterface.addCallback( "setInspectorParameters" , setInspectorParameters );

          ExternalInterface.addCallback( "setParameters" , setParameters );

          ExternalInterface.addCallback( "cpSetValue" , cpSetValue );

          ExternalInterface.addCallback( "getEditModeWidth", getEditModeWidth);

          ExternalInterface.addCallback( "getEditModeHeight", getEditModeHeight);

          ExternalInterface.addCallback( "IsReadyForSnapShot", IsReadyForSnapShot);

          ExternalInterface.addCallback( "getListOfUsedInternalResources", getListOfUsedInternalResources);

          ExternalInterface.addCallback( "getListOfUsedExternalResources", getListOfUsedExternalResources);

          ExternalInterface.addCallback( "SetExternalResources", SetExternalResources);

          ExternalInterface.addCallback( "SetInternalResources", SetInternalResources);

          ExternalInterface.addCallback( "GetWidgetAPIVersion", GetWidgetAPIVersion);

          ExternalInterface.addCallback( "SetStageModeSize", SetStageModeSize);

          ExternalInterface.addCallback( "SetCaptivateVersion", SetCaptivateVersion);

          ExternalInterface.addCallback( "SetLanguage", SetLanguage);

}

i have my functions defined properly and as stated previously its working in Edit and Stage Mode.

Thank you!

E.