|
Tom L. Hall President |
|
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
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:
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.
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.


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:

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



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:
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:
On my Website, I have included demonstrations of the use of
two of these. Click the links from above
to see those.
TCC Publishing, Inc
Internet Address: tomhall1@tcc-pub.com
Phone:
252-758-4590
Fax:
252-758-4590