Poetry machine: shuffling a list of words

Creating a phrase with randomly-changing words

Poetry machine
Create a Field sprite by using the Field Tool in the Tool Palette (Window>Tool Palette) to draw a horizontal rectangle on the Stage. Type in a list of 4 items (for example, 4 nouns), separated by commas, with no spaces before or after the commas. Note the castmember number of this Field sprite (number 34 below), then delete it from the stage. Repeat this 2 more times (for example, the second list of words might be verbs, the 3rd list might be adjectives, objects, etc.) Each time, note the cast member number of the field in the CAST before you delete it from the Stage. Create 4th, 5th and 6th Field sprites on the Stage, and don't type anything into them. Leave them on the Stage and note the Castmember number of each one (numbers 37, 38 and 39 below).


Create 3 buttons that relate to your 3 lists of words, i.e., noun, verb, object above. Attach the following script for the first one, substituting the castmember number of your first Field list for "34" in the script below, and the castmember number of your first empty Field sprite for "37" in the script below. Repeat this for the next two Field list/empty Field pairs, changing the castmember numbers accordingly.


on mouseUp
--shuffle the contents of field 34
set n = the number of items in field 34
repeat with i = 1 to 4
set pos1 = random(n)
set pos2 = random(n)
set save1 = item pos1 of field 34
set save2 = item pos2 of field 34
put save1 into item pos2 of field 34
put save2 into item pos1 of field 34
put item 1 of field 34 into field 37
end repeat
end