Use an empty string ("") for all of the On Leave events.
Tip: When you add an action to an On Enter event, you can switch right to the On Leave tab of the script editor to add an action to the object's On Leave event too. You don't have to actually exit the script editor and re-open it to assign an action to both events.
7 ) P rev i e w t h e p r oj ec t , a nd t ry ou t t h e s t a t u s t ex t b y m o v ing t h e m ou s e o ver t h e in t erac t i ve obj ec t s .
When you move your mouse over the interactive objects, the text in the paragraph object should appear and disappear.
8 ) C li ck on t h e " A bou t T e d S e ll er s " bu tt on. Wh e n t h e A bou t T e d p a g e a pp ear s , c li ck on t h e Back bu tt on t o re t u r n t o P a g e1 .
This is interesting-when you return to Page1, the "Learn more about Ted" text is still showing in the paragraph object. But the mouse isn't even on the About Ted Sellers button any more.
To understand why this happens, you just need to walk through the series of events.
First things first: when you moved the mouse over the About Ted Sellers button, this triggered the object's On Enter event. That event has a Paragraph.SetText action, which changed the text in the paragraph object to "Learn more\nabout Ted."
Then, you clicked on the About Ted Sellers button, triggering the object's On Click event...which set off the Page.Jump action, sending you to the About Ted page.
On the About Ted page, you clicked on the Back button, which triggered that object's On Click event. That event's Page.Jump action sent you back to Page1.
When you returned to Page1, the paragraph object was still showing the "Learn more about Ted" text, because that's the last thing it was told to display. The paragraph object was never told to display the empty string, because the About Ted Sellers button's On Leave event was never triggered. The Page.Jump action took you to the other page before the mouse had a chance to move off the button object and trigger its On Leave event.
Note: Objects always maintain their settings until they're changed by an action...even if you jump to another page and come back.
9 ) E x i t t h e p rev i e w.
Before moving on to the next exercise, exit the application and return to the AutoPlay design environment.
Adding Page Actions
In order to clear out the paragraph object when you return from another page, we need to add an action to one of the page's events.
There are three page events that we could use to clear out the paragraph object: On Preload, On Show, or On Close (there are more events on the page, but these are really the only ones that apply).
• On Preload is triggered after the page has been "created" in memory, but before it is actually displayed on the screen.
• On Show is triggered right after the page appears on the screen.
• On Close is triggered when the page is closed. Let's try using the On Show event first.
1 ) C li ck on t h e p a g e s u r f ace . A dd a P ara g ra ph. S e t T ex t ac t ion t o t h e On S how eve n t . I n t h e ac t ion ' s p arame t er s , s e t Obj ec t Name t o " St a t u s T ex t" a nd s e t T ex t t o "" .
We want the Paragraph.SetText action to clear out the paragraph object named "Status Text" every time this page is shown. Setting the paragraph object's text to "" will replace any existing text in it with an empty string, i.e. nothing.
2 ) P rev i e w t h e p r oj ec t . W a t c h t h e p ara g ra ph obj ec t a s y ou n av ig a t e t o a nd f r o m t h e A bou t T e d p a g e .
When you return to the first page, see how the text in the paragraph object is visible for a split second before it disappears? (If you have a really fast computer, the effect might not be that noticeable, so watch carefully.) This is because the On Show event isn't triggered until after the
page is displayed. As a result, you may see the paragraph object with the old text in it before the Paragraph.SetText action has a chance to change it.
This works, but it doesn't look very professional. It would be better if we could clear out the paragraph object before the page was shown. An easy way to do that is to put the Paragraph.SetText action on the page's On Preload event instead. That way, the paragraph object is cleared before the page is displayed.
3 ) E x i t t h e p rev i e w, c li ck on t h e p a g e s u r f ace , a nd m o ve t h e ac t ion f r o m t h e On S how eve n t t o t h e On P re lo a d eve n t .
The easiest way to move an action from one event to another is to cut and paste it.
To cut and paste the Paragraph.SetText action, click on the On Show setting, and then click on the edit button. When the script editor appears, select the line of text that contains the action. This is just like selecting a line of text in a text editor, or in Word. You can use the mouse to highlight all of the text, or you can use the keyboard, or any combination of the two.
Tip: An easy way to select a line of text is to position the cursor at the start of the line, and then press Shift+Down. (Hold the shift key, and press the cursor down key.) This will select the entire line, including the newline character at the end.