Search tutorials
The setup:
On the root of the main timeline create two input boxes. Set one
to use a variable named inbox, and set the other so that it uses a variable
named obox.
On the root of the main timeline create a button named strip_btn.
Place the snipped of code listed below on the first frame of the main timeline.
Here's the code:
strip_btn.onRelease = function(){
obox="";
var pieces = inbox.split("\r")
for(var t=0;t<=pieces.length;t++){
obox = obox + pieces[t];
}
}
stop;
Here's what it does:
When the button (named "strip_btn") is pressed and released the following takes place:
- the contents of the input box for the results is cleared.
- a new array is created by splitting the string at every occurrence of a carriage return. Since the carriage return is used as the delimiter it is left out of the array.
- a "for" loop is started with a variable "t" as the counter. It will increment from 0 to whatever number of elements were added to the array.
- each element of the array (a piece of the original text string) is appended to the string in the input box that was used for output.
notes:
-- The output could just as easily have gone into a dynamic text field..
-- It's possible to use more than one character for the delimiter.. so this
could be used as a "find and replace" tool.
| » Level Basic |
|
Added: 2003-05-19 Rating: 8 Votes: 9 |
| » Author |
| Mike Lyda is a Flash Developer and a sculptor. |
| » Download |
| Download the files used in this tutorial. |
| Download (45 kb) |
| » Forums |
| More help? Search our boards for quick answers! |
-
You must have javascript enabled in order to post comments.


Comments
There are no comments yet. Be the first to comment!