Defining visibility mode for widgets
By defining the visibility of widgets, developers can make certain facets of the widget available to users for preview or customization.
The visibility status of a widget can be set for the following views:
-
Widget tab in the property panel (Stage state): Developers can display a snapshot of the widget in this tab.
-
Widget Parameters tab in the property panel (Edit state): The snapshot of the object is usually hidden in this mode, and only the parameters that can be customized are displayed.
-
During run time: Developers can define the visibility of an object based on certain parameters.
-
Preview panel: To display the SWF file in preview mode, set wm==preview in the code.
The visibility state is undefined for widgets. Use the movieHandle.widgetParams property to set the visibility state.
Use the following tips when making visibility decisions:
-
Decide whether the widget is visible in the following cases:
-
Edit area
-
Property Inspector
-
During run time
-
Optimize the code for drawing. Excessive use of this code can slow down the player. The widget dialog box might not disappear even after the OK button is clicked.
-
Optimize the code in the OnEnterFrame function for the widget so that CPU use is kept to a minimum.
-
The drawing code is CPU intensive. Store states inside variables and use them to draw only when required.
-
To test for Flash-related issues, you can simulate the way the widget appears in the Edit or Stage mode within Flash without launching Captivate. Hard-code wm = 'Stage' and wm = 'Edit' in the OnEnterFrame function. Similarly, to simulate the behavior of the widget at run time using Flash, hard-code widgetParam, and then test.
-
Use the trace command to debug SWF files. Ensure that you delete the command during final testing as it degrades performance.
-
Ensure that you publish to the following only:
Defining the preview movie
You can provide a dummy SWF file that appears in the preview area when the user selects a widget in the Widget panel. The dummy SWF file gives users an idea of how the widget works.
Explore the PieChart.fla to get a better understanding of the procedure for defining a preview movie.
-
Open the PieChart FLA file for the pie chart in Flash. This file is available on your computer in the \\Program files\Adobe\Adobe Captivate <Version number>\Gallery\Widgets folder.
-
In the Property Inspector, select the movie outside the Stage. The name of the movie PieChart_prvw is displayed in the Property inspector.
-
Right-click the frame containing the action, and select Actions.
-
Locate the following piece of code.
if (wm == 'Preview')
{
PieChart_prvw._visible = true;
}
The code sets the movie to preview mode and displays the movie in the preview area when the user selects the widget. If you set the visibility to false, the widget is not displayed in the preview area.
Sample code for defining visibility for different modes
function cpSetValue( variable:String , val )
{
if(variable == 'movieHandle' ) {
movieHandle = val;
mainmov = movieHandle.getMovieProps().variablesHandle;
}
if (variable == 'widgetMode')
{
widgetMode = val;
}
}
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
{
button1._visible=true;
}
else if (wm == 'Preview')
{
button1._visible=false;
}
else //this is the stage mode
{
button1._visible=true;
}
}