Tom L. Hall

President

 

TCC Publishing Newsletter

 

Issue 3

 

January 15, 2007

 

 


Welcome to this issue of my Newsletter.  In this issue, I will share with you some of the very basic Shared Scripts and Shared Actions I use in a lot of my projects.  This information is aimed towards the beginners.

 

In this Issue:

 

Shared Scripts vs Shared Actions

Sample Shared Scripts

Sample Shared Actions

Denny Dedmore’s Shared Actions


Shared Scripts vs Shared Actions

 

First, a Shared Script or a Shared Action is a book level resource that can then be associated with any object within the book.  The major difference between a Shared Script and a Shared Action is how each will work when deployed:

 

  • Shared Script – written in OpenScript and therefore will only work for a Native ToolBook Deployment
  • Shared Action – written in the Actions Editor and will work both for Native Deployment as well as HTML Deployment

 

When I go into a project knowing that the Deployment will be HTML, then I take the following approach.  I will write a few very simple but useful Shared Scripts that primarily will be used to help me make sure that a book is set up the way I want it to be set up before I publish to HTML.  For example, if I have a page where there is a Learner action that shows something, such as a image that is displayed when a button is clicked, then I will write a short Shared Script that assures that the object is initially hidden.  The reason I make this a Shared Script as opposed to a normal script assigned to the object is that I will likely have several cases where I will do the same thing.  Then if there are actions at runtime that can be used several times and the action is very generic, then I will write a Shared Action and assign it to an object instead of writing the same action several times for each individual object.  For example, if there is an object that is made visible by a Learner action and I want to object to be initially not visible each time the Learner visits the page, then I will write a Shared Action to make sure this happens.

 

The bottom line is this for me as I develop: Shared Scripts are more likely to be used to help me be a better Author while Shared Actions are there to cause things to happen when the application is viewed by the Learner, either natively or in HTML.

 

top


Sample Shared Scripts

 

In the above section, I gave one example of the use of a Shared Script.  I want to make sure that after testing an exercise where something is made visible as a result of a Learner interaction, that whatever is made visible is set back to not visible as I save the book prior to deployment.

 

Here’s a Shared Script to show and hide objects as desired:

 

 

 

Notifyafter asym_reset

          hide self

end

 

Notifyafter author

          show self

end

 

Notifyafter reader

          hide self

end

 

 

 

Now, each time I do a reset book and save or switch to Reader level, the object that this code is assigned to is automatically hidden.  As a bonus, when I switch to Author, I want to show the object instead of having to constantly use the Show All Objects command.  Note that the use of self makes this a very generic script that then can be assigned to most any object on the page or background.

 

  1. To use this, just select the text in the box, and copy it to the Clipboard. 
  2. Then open your ToolBook and go to the Resource Manager (Object, Resources). 
  3. Change the type to sharedscript and click New.
  4. Paste the selected text from above into the Script Editor.
  5. Save this and name the Shared Script Hide_Me.

 

 

 

  1. Now, assign this to the object you want to show and hide.  The quickest way is to right-click over the object as shown below.

 

 

 

 

I will do something like this if there is a text field that either is used to solicit Learner input of if the field is dynamically populated with text at runtime.

 

 

 

Notifyafter asym_reset

          clear text of self

end

 

 

I would call this Shared Script Clear_Me.

 

Now, suppose we have an exercise where the Leaner must do something on a page before a Next button is enabled, thus the button must initially be set to disabled:

 

 

 

Notifyafter asym_reset

          enabled of self=false

end

 

 

I would call this Shared Script Disable_Me.

 

After a few uses of these very simple Shared Scripts, you hopefully will begin to see how you can make things a lot easier on yourself while assuring that when you deploy your book, objects are in the initial conditions you want them to be.  Likewise, you can begin to think of some of your own Shared Scripts.

 

Here’s one that I have used quite a bit and is one that came from Peter Hoyt.

 

 

notifyBefore asym_reset

          my fillColor = white

          my bounds = 1680,3375,13545,6105             

end

 

notifyAfter Author

          my fillColor = yellow

end

 

notifyAfter enterPage

          if syslevel = author

                   my fillColor = yellow

          else

                   my fillColor = white

          end

end

 

 

This one is normally assigned to a text field where we have set the fillcolor to white, borderstyle to none, and draw to transparent.  The point being that we want to be able to see the bounds of the field while at Author but at Reader level we want only to see the text in the field.  Notice how we also use this to control the position and size of the object.  Likewise, while at Author level, we want to make sure we see the field each time we enter the page.

 

At Author, we see this:

 

 

At Reader, we see this:

 

 

top


Sample Shared Actions

 

In most all of my projects, I use several very simple Shared Actions to perform some basic tasks at runtime.

 

  1. To create a Shared Action, choose Object, Shared Actions from the menu bar.  You also can choose Action, Shared Actions from within the Actions Editor of any object.
  2. Click New from the Shared Actions dialog box and write the shared action.
  3. A common one that I write is one that I use to hide objects at runtime that have been made visible by some Learner interaction. That action is shown here.

 

 

  1. Save this and name it Hide_Me just as we did for the Shared Script.  Remember, the Hide_Me Shared Script is used mainly by you as you switch between Author and Reader level and when you save your book, whereas this Shared Action with the same name (it did not have to be), is just Actions Editor code that is there to be executed when you “call” it at runtime (either Native tbk or HTML).

 

 

 

  1. Now, you can assign it to an object and an event.  In the example shown below, I have assigned this to the On unload page event for a graphic.  The assumption here would be that this object would be initially not visible and a button or something would be on the page that the Learner clicks to show the graphic.  Then when we leave the page, we hide it, so it is hidden upon the next visit.

 

 

 

 

Here is another one I use quite a bit when I have a text field that the Learner types text into or a case where I have used the Actions Editor to populate the field with text:

 

 

Notice that I have named this Shared Action Clear_Me and also assigned it to an On unload page action.

 

The general rule for me is that if I see I need code that is very generic more than twice, I will create the Shared Action and assign it (Execute it) as needed. 

 

Other useful Shared Actions might be:

 

  • Disable a button that is initially disabled and then enabled as a result of a Learner’s action
  • Reposition an object that might have been moved
  • Show an object that might not be initially visible but hidden by the Learner’s action

 

top


Denny Dedmore’s Shared Actions

 

The previous section provided a look at some very basic uses of Shared Actions.  Denny Dedmore has done a great job of providing a library of Shared Actions.  Click here to view the entire list and gain access to downloads of his Shared Actions.

 

Denny’s Library includes:

 

  • Item – allows you to get an item from a list such as a comma-separated list
  • TrimString – trims leading and trailing characters
  • ClearChars – clears one or more characters in a string
  • ReplaceChars – replaces one or more characters in a string

 

On my Website, I have included demonstrations of the use of two of these.  Click the links from above to see those.

 

top


 

 

TCC Publishing, Inc

2055 Cherry Stone Lane

Greenville, NC 27858 USA

Internet Address: tomhall1@tcc-pub.com

http://tcc-pub.com

Phone: 252-758-4590

Fax: 252-758-4590