Hide/show the TOC
The above movie demonstrates the show/hide widget just insert the show widget and the TOC will display when that frame is reach, use the Hide widget to make the TOC disappear
Download Hide/Show buttons widget
AS2 Widget source
//..........................Template for static widget(AS2)....................
var my_fmt:TextFormat = new TextFormat();
my_fmt.size = 3;
my_fmt.bold = false;
//flash construct to use external interface : This is needed to use flash functionality for communication between two swfs
import flash.external.ExternalInterface;
var widgetMode:String = '';
var varHand : Object = null;
//----------------------------
//Captivate App will not recognize a Static Widget unless this function is implemented and returns true
function isStatic():Boolean
{
return true;//denotes that this is indeed a Static Widget
}
//a object needs to be created and values filled in . This is taken by captivate and stored as //xml string. This is the mean to pass values between captivate and widget swf.
function getInspectorParameters():Object
{
var _parameters: Object = new Object();
//set the data in _parameters fields. This is called by captivate to get the values of widget swf
return _parameters;
}
// whenever widget is inserted the widget swf is passed on the parameters stored inside captivate so that it is drawn in updated stage.
function cpSetValue( variable:String , val )
{
if(variable == 'movieHandle' ) {
movieHandle = val;
varHand = movieHandle.getMovieProps().variablesHandle;
varHand.ShowHideTocRight_mc._visible = false;// hides the >> arrows that are on screen to open the TOC
varHand.ShowHideTocLeft_mc._visible = false;// same as above
varHand.TOCContainer_mc._visible = false;// false TOC is not displayed - true TOC is displayed
//using varHand the variables can be accessed for eg. varHand.rdcmndPause = 1;
}
if (variable == 'widgetMode')
{
widgetMode = val;
}
}
function setInspectorParameters(inParam:Object): Void
{
}
//is called whenever widget needs to be drawn as per the changed
//parameters like OK to widget dialog and stage swf is updated with the current values.
function setParameters(inParam:Object): Void
{
if (inParam.variable != undefined)
{
//redraw the widget as parameters has changed
}
}
//------------------------------------------------
//Register all the functions with ExternalInterface
var wasSuccessful:Boolean = true;
wasSuccessful = wasSuccessful and ExternalInterface.addCallback("isStatic",null,isStatic);
wasSuccessful = wasSuccessful and ExternalInterface.addCallback("getInspectorParameters",null,getInspectorParameters);
wasSuccessful = wasSuccessful and ExternalInterface.addCallback("setInspectorParameters",null,setInspectorParameters);
wasSuccessful = wasSuccessful and ExternalInterface.addCallback("validateParameters",null,validateParameters);
wasSuccessful = wasSuccessful and ExternalInterface.addCallback("getWidgetInfo",null,getWidgetInfo);
wasSuccessful = wasSuccessful and ExternalInterface.addCallback("setParameters",null,setParameters);
wasSuccessful = wasSuccessful and ExternalInterface.addCallback("cpSetValue" , null , cpSetValue );
//take care of optimised drawing inside this function. Check the widgetMode , widgetParams and draw accordingly
this.onEnterFrame = function()
{
var wm:String = widgetMode;//this variable will be provided by Captivate App or Captivate Movie
if(wm == undefined)
{
wm = widgetMode;
}
if(wm == undefined)
wm = 'Stage';
if(wm == 'Edit')//Property inspection inside Captivate app
{
this.createTextField("_Ins",this.getNextHighestDepth(), 0, 5, 100, 20);
this._Ins.autoSize = "left";
this._Ins.wordWrap = true;
this._Ins.text = "This Widget will HIDE the TOC";
this._Ins.setTextFormat(my_fmt);
this._Ins._visible = true;
}
else if(wm == 'Preview')//The code here is used for previewing the widget in the preview window of widget panel
{
txt._visible = true;
}
else //On stage scrubbing/live preview inside Captivate app (OR) at runtime inside Captivate movie.
{
if(movieHandle.widgetParams != undefined && movieHandle.widgetParams != "")
{
var x:XML = new XML(movieHandle.widgetParams);//parse XML and transfer the values to swf variables
}
}
}
Comments (2)
-
|Registered |2009-11-03 15:39:47 thinkworks - Hide/Show TOC in AS3 or Source Code for AS2?Any chance of sharing the source code for this widget? I have a client who wants this functionality but needs it to be AS3. If I'm able to convert it, I'd be happy to make it available to the Captivate community.
Thanks,
--Garry
Only registered users can write comments!
Powered by !JoomlaComment 4.0 beta1


I'd also like to be able to 'collapse' all the folders of a long TOC until the first slide of that section, any thoughts?