In my first experiment, I made each word in the nursery rhyme an individual text object. These were all given their own layer on the timeline.
On each layer containing a text object, I extended the frames as far as frame 10 and inserted keyframes on every frame within the span.
At each frame I swapped around the positions of the words that made up the rhyme. This was done at random.
I created a button that could trigger the words to mix when clicked. It would do this by sending the playhead to a random frame on the timeline. The words were in different positions on each frame. I gave the remix button the instance name remix_btn.
I added a new layer called 'actions', to contain actionscript code. On frame 1 of this layer, I added the following code to the actions panel :
When the code is executed, the remix button can be clicked to cause the words of the nursery rhyme to jumble.
The nursery rhyme could be refreshed by adding a separate button that would take the playhead back to frame 1. I called this button refresh_btn to be referred to in actionscript.
The following code was added to the actions panel:
When the code is executed, the nursery rhyme becomes visible in movie window. And when the 'remix' button is clicked, the words shuffle randomly.
This experiment is more effective than working on the timeline, as the shuffled words are positioned entirely at random.
However, I could improve this remix by allowing input from the user, so that the words being remixed are not fixed.
For this experiment I placed each word in a new position for every frame on the timeline. This was a lengthy process and required me to provide the outcomes of the remix. Since I limited the timeline to 10 frames, I only provided 10 different arrangements of the remix. The actual number of possible outcomes, for arrangement of the 12 words, would be a number too great for the timeline to be sufficient. I would therefore like to create this remix using actionscript to create each outcomes.
In this experiment, I created a button on the stage and name it 'remix_btn'
In the layers panel I added a separate layer for the actionscript code (actionS).
Placing text objects in actionscript, is often achieved using a STRING variable. However, for the remix of nursery rhyme, the words needed to be arranged in a sequence so that each word could be accessed separately.
For this purpose, I found discovered following method:
See the Adobe forum: ARRAY
Here, each word of the rhyme is entered as an element in an array sequence. The first value in an array is numbered as (0) and each value thereafter is numbered consecutively (1), (2), (3) etc.
For this experiment to work, the array needed to be shuffled in the event of the 'remix' button being clicked.
I discovered the following tutorial to help me work out the code:
Go to tutorial >>>
The most efficient way of shuffling the values, seemed to be the Splicing approach.
In this approach, an empty array is created with the same number of elements as the original array. The empty 'slots' are filled by pulling a value from a random 'slot' in the original array.
The splice method then removes the slot from the original array to ensure that values aren't picked twice.
Therefore the length of the original array grows shorter as each value is picked.
In the event of the button being clicked:
-create a new array (that is the same length as the original)
-fill the new array with the a splice of the original array (all in random positions)
A text field needed to be added to the stage, on a new layer. This is so that the shuffled array could be outputted on the stage.
I created a text area and gave it the instance name 'text_base'. I also changed the field to 'DYNAMIC TEXT' in the property inspector.
The original array needed to appear in the text field, as if it were a text string. This is acheived using the concat method.
The following code concatenates the array in the text field, and ensures that the words are posted with spaces between them. It had to be specified that the first value in the array; i.e Georgie, should be written as normal, whilst every consecutive value should be preceded by a space to separate it from others words:
See the Adobe forum: Array_concat
For this experiment I wanted to create a text area where selected pieces of text could be inputted. The body of text collected in the area could then be remixed together.
I picked a selection of nursery rhymes that would be available as input text.
The user should be able to click on any of the rhymes in any order. The resulting text block would be the material for a remix.
I used the flash Components. "tile list" and "text area".
The nursery rhymes would be added to the tile list as thumbnails, and the lyrics of the rhyme would only appear in the text area if that thumbnail was clicked.
I gave the tile list an instance name 'thumbnails_tl', and the text area an instance name 'text_base'
I added a new layer for the action script code and began adding items to the tile list using the addItem method.
The text for each nursery rhyme would be stored as the data for each thumbnail. I needed to create a function which would call the data when the thumbnail was selected.
The above code sends the data of the selected thumbnail to the text area. However, when a different thumbnail is selected, the data is replaced by it's corresponding text. Therefore only one nursery rhyme can be present in the text area at any time.
I needed to adapt the code so that when data was added to the text area, it would sit beneath any text that was already present.
I used the 'if' statement to outline that if text was present in the text area, the new data should be entered 2 lines down '\n\n'
Or 'else', if there is not text present in the text area, the data should be added to the text area as normal (with out new line spaces)
This was more successful:
view sample outcomes...
I then needed to remix the text in the text area.
I created a remix button on a new layer in the timeline.
I gave it the instance name 'remix_btn'
I also needed to create a new text field to output the results of the remix. I added a new layer to the timeline and created a text field with the instance name 'result_text'
It was necessary to create a event listener for the remix button, that would execute a function and shuffle the words.
To create the shuffle, I was able to use the same code from the previous experiment, which had 'spliced' the array.
However I needed to turn the text into an array of individual words that could be referred to independently.
In this code I adapted the names for the text field so that it referred to result_text where necessary.
The 'rhyme' variable was copied over from the previous experiment. It needed redefining in this experiment since, in the previous code it was already an array.
Lines such as 'var rhymeCopy:Array = newArray(rhyme.length);' will not work in the code above, until 'rhyme' is defined.
I searched online for a method that would allow me to create an array from a text string.
I found the method, 'SPLIT'
This successfully made a remix of the text within the text_base area.
To tidy up, I could also get rid of the new-line spaces in the 'result_text box', so that all the nursery rhymes merged together.
To acheive this I decided to make a copy of the text in the 'text_base'
The copy could also be concatenated as each thumbnail was selected. At this point however, the call for a new line could be removed '\n\n'
When it comes to defining the variable 'rhyme', the text_base_copy is used instead of the text_base. At this point both contain the same text, but the text_base_copy does not have spaces between the paragraphs.