• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL

Lesson 10. Drag-and-Drop Interactions > Providing Dynamic Feedback

Providing Dynamic Feedback

You're almost done with the drag-and-drop functionality. However, snapping into place is hardly sufficient feedback for users. In this task, you will add the dynamic text feedback that tells them whether they dropped the monster in the correct target.

Select frame 1 of the dynamic text layer. Select the text tool. In the Property inspector, set the type to Dynamic Text, the font to Verdana, size 12, and make its color a dark blue (#000099). Hold down the Shift key and drag out a text field that is four lines high and about as wide as the info box above it.

The dynamic text box you create in this step will contain the text feedback for users as they drag and drop monsters in various places.

With the new text field still selected, use the Property inspector to give it an instance name (not variable name) of dragtext. The line type should be Multiline. Render Text as HTML should be toggled on, while Selectable and Show Border Around Text should be toggled off.

These settings prepare the text field so it can be used to provide feedback.

Select frame 1 of the actions layer, and enter the following line of script in the Actions panel, beneath the stop(); line:

							dragtext.htmlText="Drag a monster to its designated post.";

This line gives the dragtext text field a text string to display when the movie first loads. Again, it uses the htmlText property, which causes the field to render HTML tags, rather than leaving them as plain text.

Test the movie to make sure the text loads.

When you test the movie, the text string should appear in the dragtext field, in blue.

Return to the main movie, and select the chiron instance. In the Actions panel, enter the following text, beneath the this._y=78; line:

							_root.dragtext.htmlText="<b>Correct</b><br>Chiron the Centaur guards the
sinners immersed in the river of blood.";


This code can be found in the script_html.txt file, beneath the Chiron heading.

This line causes the dragtext field to display a message confirming that the user dropped the chiron instance on the correct target. Like the two lines above it, which snap the instance into place, this text is triggered to appear when the hitTest() expression evaluates to true.

Beneath the this._y=342; line, add the following line of code. Test the movie to make sure it works.

							_root.dragtext.htmlText="<b>Incorrect</b><br>Please try again!";

This line tells users that they placed the monster in an incorrect location.



Not a subscriber?

Start A Free Trial

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint