# Random Letter Cycling - Again

**URL:** <https://forum.kirupa.com/t/random-letter-cycling-again/242540>\
**Category:** flash\
**Created:** [October 27, 2007, 5:21am UTC](https://forum.kirupa.com/t/random-letter-cycling-again/242540 "2007-10-27T05:21:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pherank](https://avatars.discourse-cdn.com/v4/letter/p/4af34b/32.png) [@Pherank](https://forum.kirupa.com/u/Pherank)\
**Post date:** [October 27, 2007, 5:21am UTC](https://forum.kirupa.com/t/random-letter-cycling-again/242540/1 "2007-10-27T05:21:44Z")

</div>

I’d like to reuse this old code, but need to have it rewritten for the main timeline. I can’t seem to get it right. Anyone else? You need to create a textfield and give it the variable name of “letter” (No instance name is needed). Then convert the textfield to a movieclip named “my\_mc” and drag that onto the stage. Place the following code on it:

```auto

onClipEvent (load) {
    if (_name == "my_mc") {
        name = "BUSHANDCHENEY";
        for (x=0; x<name.length; ++x) {
            this.duplicateMovieClip("let"+x, x);
            _parent["let"+x]._x += x*15;
            _parent["let"+x].endLetter = name.charAt(x);
        }
        _root.alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        _alpha = 0;
    } else {
        cycle = true;
    }
}
onClipEvent (enterFrame) {
    if (cycle) {
        if (this.letter == endLetter) {
            ++_root.count;
            cycle = false;
        } else {
            this.letter = _root.alphabet.charAt(random(_root.alphabet.length));
        }
    }
}

```

Thanks for any help.
