Slide Object Properties

This page explains how to use command variables related to changing properties of a slide object.

Dynamically moving visual objects around the stage is a basic requirement to build most games. Therefore, these variables have a deeper level of complexity to them than most variables in CpExtra. Beyond that, the ability to change the score reported to the quiz is a commont requirement for many interactions. This funcitonality is included in the xcmndScore variable.

xcmndPosX

Parameters

In SET Mode

  1. The name of a slide object OR an @syntax query OR the name of a variable that contains slide object name / @syntax query.
  2. A number OR the name of a variable that contains a number OR the keyword: Default

In GET Mode

  1. The name of a variable
  2. The name of a slide object OR the name of a variable that contains a slide object's name.

Modes

xcmndPosX has two modes which it will automatically jump between depending on what kind of parameters you give it. These modes are:

  1. Moving slide objects horizontally across the stage (this is called SET mode)
  2. Assigning Captivate Variables with how many pixels from the left a slide object is current horizontal positioned (this is called GET mode)

SET Mode Description

Set mode allows you to set exactly how many pixels from the left the slide object should appear. The following code would cause an object named Caption_1 to immediately move ten pixels from the left of the stage.

Assign | xcmndPosX with Caption_1, 10

The First Parameter In Depth

The first parameter can be the name of a slide object, as shown above. This method will also allow you to change the position of objects on other slides.

It could also be an @syntax query pointing to multiple slide objects on the current slide. So if you had a slide with three objects: Caption_1, Caption_2, and Caption_3, you could move them all to the very left of the stage with the following code.

Assign | xcmndPosX with Caption_@, 0

You could also use the name of a variable whose value contains a slide object name. Assuming you had a user variable named MyVar in your course, the following code would move Caption_2 to 100 pixels form the left.

Assign | MyVar with Caption_2
Assign | xcmndPosX with MyVar, 100

You could also use a variable which contains an @syntax query. The following code would move Caption_1, Caption_2, and Caption_3 1000 pixels from the left of the stage.

Assign | MyVar with Caption_@
Assign | xcmndPosX with MyVar, 1000

The Second Parameter In Depth

The second parameter can be a number, as shown above.

It can also be the name of a variable whose value is a number. Assuming you had a user variable named MyVar in your course, the following code would move Caption_1 to 25 pixels from the left.

Assign | MyVar with 25
Assign | xcmndPosX with Caption_1, MyVar

​If you want to move a slide object back to the position it had when the slide began, you can do so using the Default keyword (not case sensitive).

The following code would move Caption_1 back to its original horizontal position.

Assign | xcmndPosX with Caption_1, Default

GET Mode Description

As it is quite common to want to set a slide object's position in relation to another slide object, it is important to be able to know what an object's current horizontal position is. This is what GET mode allows you to do.

GET mode will retreive a slide object's current X position and saves it in a variable.

Let's say you had a slide with two captions named Caption_1 and Caption_2. The project also contains a user variable named MyVar. You could save Caption_1's X position into MyVar with the following code. 

Assign | xcmndPosX with MyVar, Caption_1

If you wanted to move Caption_2 to be in the same location horizontal as Caption_1, you could do so with the following code.

Assign | xcmndPosX with MyVar, Caption_1
Assign | xcmndPosX with Caption_2, MyVar

In the above code, the first line is using GET mode and the second line is using SET mode.

For GET mode to work, the first parameter MUST be a variable name.

The second parameter on the other hand could be either a slide object name (as shown above) or the name of a variable whose value contains a slide object name.

If we expand the example above to say the project also has a variable named MySlideObject then the following code would move Caption_1 to the same horizontal position as Caption_2.

Assign | MySlideObject with Caption_2
Assign | xcmndPosX with MyVar, MySlideObject
Assign | xcmndPosX with Caption_2, MyVar

xcmndPosY

Parameters

In SET Mode

  1. The name of a slide object OR an @syntax query OR the name of a variable that contains slide object name / @syntax query.
  2. A number OR the name of a variable that contains a number OR the keyword: Default

In GET Mode

  1. The name of a variable
  2. The name of a slide object OR the name of a variable that contains a slide object's name.

Description

xcmndPosY is identical to xcmndPosX, with the exception that it will move slide objects along the vertical axis instead of the horizontal axis.

xcmndWidth

​Parameters

  1. The name of a variable
  2. The name of a slide object OR the name of a variable that contains a slide object's name

Description

xcmndWidth works much like xcmndPosX and xcmndPosY except it doesn't have a SET mode. It only allows you to save a slide object's current width into a variable. It does not allow you to change an object's width. The reason why we have not allows you to change an object's width is because it seriously distorts the slide object to an unimaginably ugly degree. 

xcmndWidth can be used in tandem with xcmndPosX to position objects in relation to other objects.

For example, let's say you have a slide with two captions: Caption_1 and Caption_2. This project also has three variables: TempVar1, TempVar2 and TempVar3.

The following code would position Caption_2 directly to the right of Caption_1.

Assign     | xcmndPosX with TempVar1, Caption_1
Assign     | xcmndPosWidth with TempVar2, Caption_1
Expression | TempVar3 = TempVar1 + TempVar2
Assign     | xcmndPosX with Caption_2, TempVar3

xcmndHeight

​Parameters

  1. The name of a variable
  2. The name of a slide object OR the name of a variable that contain's a slide object's name

Description

xcmndHeight works exactly the same as xcmndWidth except it saves the slide object's height to a variable.

xcmndScore

Parameters

In SET Mode

  1. The name of an interactive slide object OR an @syntax query OR the name of a variable that contains slide object name / @syntax query.
  2. A number OR the name of a variable that contains a number

In GET Mode

  1. The name of a variable
  2. The name of an interactive slide object OR the name of a variable that contains a slide object's name.

Description

SET Mode Description

Set mode allows you to change the score that an interactive object has reported to the quiz.

For example, say you have a button set to report to the quiz. This button is called SubmitButton. It will add four points to the quiz score if successful.

In the published output, when you click that button, four points will be added to the score.

However, this button might be used to submit an interaction such as the following.

You have a correct answer in mind for each text entry box. If the learner gets all four answers correct (first name, last name, email, and password), then you want the SubmitButton button to score four points to the quiz as it currently does. However, if you get three out of four of the answers correct, then you want the button to report three points.

This is called partial scoring and can be achieved with xcmndScore's SET mode.

You can change the SubmitButton button's score to 3 with the following assignment:

Assign | xcmndScore with SubmitButton, 3

In this case however, you would most likely want to change SubmitButton​'s score based on a Captivate variable.

Let's say in the above interaction we had a variable called InteractionScore. When we click the submit button, it runs an advanced action which checks the value of each text entry box (first name, last name, email and password) to see if the correct answer has been entered into each one. If the correct answer HAS been entered, the value of InteractionScore in incremented by one. If the correct answer HAS NOT been entered, InteractionScore's value IS NOT incremented. After we have evaluated all four text entry boxes, the InteractionScore variable will hold the score that we want the SubmitButton to have. So we can assign that score to SubmitButton with the following code:

Assign | xcmndScore with SubmitButton, InteractionScore

Of course you could use any number, even a number above the buttons maximum score (which is four as entered above). You could even enter a negative score to subtract points from the quiz.

However you must keep in mind the following points

  1. LMSs usually record course success in percentage, considering 100% ideal. If you change an interactive object's score to be higher than its maximum score, this could lead to reporting a score of over 100% which many LMSs do not know how to interpret, therefore leading to unexpected behavior in the LMS.
  2. In the same way, LMSs do not expect to be receiving a negative score. So if you do use negative scoring in your course, it may be wise on the last slide to check the score of the course, and if it is under zero, use xcmndScore to change the score of one interactive object to bring the total score up to zero.

Note: For this variable to work, the interactive object need not be on the currently viewed slide. The interactive object's score can be changed from anywhere in the project.

GET Mode Description

Sometimes instead of changing an interactive object's score, you want to KNOW how many points an interactive object is currently adding to the course score. This can be achieved using xcmndScore's GET mode.

The goal of GET mode is for CpExtra to read the interactive object's score, and then assign that number to a Captivate variable. To indicate to xcmndScore that you want to use GET mode instead of SET mode, you must change the order of the parameters.

The first parameter must be the name of a Captivate variable.

The second parameter must the the name of the interactive object whose score you wish to read.

So if you have an interactive object called MyButton and you want to send its score to the MyVar Captivate variable, you would write the following code.

Assign | xcmndScore with MyVar, MyButton

xcmndMaxScore

Parameters

In SET Mode

  1. The name of an interactive slide object OR an @syntax query OR the name of a variable that contains slide object name / @syntax query.
  2. A number OR the name of a variable that contains a number

In GET Mode

  1. The name of a variable
  2. The name of an interactive slide object OR the name of a variable that contains a slide object's name.

Description

SET Mode Description

This variable is very similar to xcmndScore. Except that instead of changing what score an interactive object has reported to the quiz, xcmndMaxScore changes what is considered the interactive object's maximum score. In other words, how many points this interactive object must report if it is to be considered 100% successful.

Within Captivate, this maximum score is set in the Properties panel, under the Actions subsection, under the Reporting heading.

In the above screen shot, this interactive object is set to have a maximum score of four points. In the published export, if we wanted to change this maximum score to ten points, we could do so with the following code (assuming the item name of the interactive object is InteractiveObject).

Assign | xcmndMaxScore with InteractiveObject, 10

The potential reason why you would want to use this, is because LMSs do not accept scores of over 100%. So if you have an interaction where the normal score is four, which should be considered successful, but there is also an exceptional score of six if they enter a really really good answer, then we can use xcmndMaxScore to ensure we will not let the overall course score go over 100%.

First we can create a variable called ScoreTemp.

Then we can use xcmndScore's GET mode to assign the current score of InteractiveObject and assign it to the ScoreTemp variable.

Assign | xcmndScore with ScoreTemp, InteractiveObject

Finally, we use xcmndMaxScore to change InteractiveObject's maximum score to be the same as the value in the ScoreTemp variable.

Assign | xcmndMaxScore with InteractiveObject, ScoreTemp

​GET Mode Description

If instead of changing an interactive object's maximum score, you want to know what an interactive object's maximum score is, you can do so by using xcmndMaxScore's GET mode.

The goal of GET mode is for CpExtra to read an interactive object's maximum score, and then assign that number to a Captivate variable. To indicate to xcmndMaxScore that you want to use GET mode instead of SET mode, you must change the order of the parameters.

The first parameter must be the name of a Captivate variable.

The second parameter must the the name of the interactive object whose maximum score you wish to read.

So if you have an interactive object called MyButton and you want to send its maximum score to the MyVar Captivate variable, you would write the following code.

Assign | xcmndMaxScore with MyVar, MyButton

IF YOU LIKE WHAT YOU'VE READ ABOVE, THERE'S PLENTY MORE!

Join more than 2500 other Adobe Captivate users just like yourself and receive regular troubleshooting tips, illustrated tutorials, technical information, and creative solutions to real-world e-learning development issues. (See an example here.) Click the button below to join our community.  It's completely FREE!