Select Project > Variables.
The following tutorial helps you get started with using scripting in Adobe Captivate Classic.
You have been asked to create a login slide with fields to enter the user name and password.
When the user enters the correct values, the following actions take place:
The project moves to the next slide.
A text caption in the next slide displays the message, "Welcome <user name>".
The default e-mail editor opens with the e-mail ID of the person that must be informed of the login.
When the user enters incorrect information, a text caption is displayed asking the user to reenter information.
Create variables for the project
-
-
Create a variable named varUserName, with the value user. For more information, see Create a user-defined variable.
-
Create a variable named varPassword with the value password.
Create objects for the slides
-
In an open project, insert two text entry boxes for the user name and password. The text entry boxes must be set to act as form fields.
Merk:To set a text entry box to act as a form field, select it and then deselect Validate User Input in the Property Inspector.
-
Delete the Submit button from the User Name field.
-
Set the following options for user name:
In Actions, go to On Success, and select No Action.
Deselect Infinite Attempts.
Merk:This option is disabled automatically when you disable Validate User Input.
- In the Action area of the Property Inspector, select Continue in the Last Attempt field.
- Associate the field with the variable varUserName in the Var Associated field (General area of the Property Inspector).
-
Double-click the text entry field for the password, and set the following options:
In the On Success field, select Continue.
Deselect Infinite Attempts.
In the After Last Attempt menu, select Continue.
In Variable Associated, select varPassword.
-
Insert a text caption and do the following:
Enter the following text on the caption: Invalid username/password. Please try again.
In Name, change the name of the caption to FailureCaption. Deselect the Visible option. Doing so hides the caption until the conditions in the script enable the caption.
-
Insert a blank slide.
-
Insert a text caption with the text Welcome and the variable varUserName in the format Welcome $$varUserName$$.
-
Save the project as variables.cp.
Create an advanced action for the login slide
The advanced action for the login slide must do the following:
Check whether the correct information has been entered in the login and password fields.
Move to the next slide if the information is correct.
Stay at the login slide if the information is incorrect and display a text caption requesting the user to reenter the login information.
-
Select Project > Advanced Actions.
-
In the script window, do the following:
-
Click Conditional Actions as the Action Type.
-
Specify the name of the script as ‘validate’.
-
In the IF section, double-click the rows and select the appropriate options in the drop-down lists. See the following illustration for the options to select:
-
In the Actions section, double-click the first row and specify the action as Continue.
-
Click the Else header, double-click the rows, and specify the appropriate options as shown below.
-
Now look at individual lines of the code to understand what they do.
The code checks whether the user has used the user and password login credentials in the respective fields.
This project moves to the next slide if the user name and password are entered correctly.
If the user information is incorrect, the project stays at the login slide. The text caption with the name FailureCaption is displayed.
Create an advanced action for the e-mail and welcome slide
In the script window, do the following:
create a script named sequential action with the following code:
-
Click Standard Actions as the Action Type.
-
Specify the name of the script as ‘sequentialaction’.
-
Double-click the rows and specify the options as shown below.
Now look at individual lines of the code to understand what they do.
On successful login, the code opens up the default e-mail editor with the e-mail ID xyz@company.com displayed in the To field.
Displays the text caption containing the text, "Welcome <login name>".
Apply the advanced action to the login slide
-
Double-click the login slide, and set the following actions in the Property Inspector:
On Enter: Select Continue.
On Exit: Select Execute Advanced Actions, and in the Action menu, select Validate.
Apply the advanced action to the next slide after login
-
Double-click the display slide, and in the Property Inspector, set the following actions:
On Enter: Select Execute Advanced Action, and choose sequential action in the Action menu.
On Exit: select Go To Next Slide.
Run the project, and check whether the aims of the project have been achieved.