Jump to content
Search Community

random letter cycling

SyntaxMind test
Moderator Tag

Recommended Posts

So I know endArray cycles through numbers to end with a target number. I'm wondering if this can be done with letters and words. Has anyone tried using the tweening engine to do this? I'm thinking more splittextfield but I'm wonder if anyone can steer me in a good direction.

Link to comment
Share on other sites

Yea seen that tutorial which is exactly how I would like it to be done. Only I haven't yet figured out OOP concepts yet and I can work them in. That's why I figured the greensock approach would be better. I'll figure it out somehow.

Link to comment
Share on other sites

this is 1 way of doing it with endArray, but it cycles through all the characters for the same amount of time concurrently. Also since capital and lower case letters aren't consecutive, a few non-alphanumeric characters show up if you add upper case characters. this is really rough, but it works:

 

import com.greensock.*; 
import com.greensock.easing.*;

trace(String.fromCharCode(97));

var word:String = "greensock";



//array to be tweened
var myArray:Array = []

//array storing end values
var finalArray:Array = []

//array that constantly updates for display purposes
var updatedArray:Array = []

for(var i:uint=0; i 	//add a bunch of a chars to myArray
myArray.push(97);
//populate final array with numeric character codes
finalArray.push(word.charCodeAt(i));
}



TweenMax.to(myArray, 1, {endArray:finalArray, ease:Linear.easeNone, onUpdate:showIt});



function showIt(){

for(var i:uint=0; i 		updatedArray[i] = String.fromCharCode(Math.floor(myArray[i]));

  }
  trace(updatedArray.join(""));
	//add a dynamic textfield called display_txt to your fla
	display_txt.text = updatedArray.join("");
}

 

that will generate:

 

bdaacdcab

bdaadedac

bebbdedac

bebbdedac

bfbbefead

cfbbegead

cgbbfgfad

chbbfhgae

cibbgigae

diccgjhbf

djcchjhbf

dkcchkibf

dkccilibg

elccimjbg

emccjnkbh

emddjnkbh

enddkolbi

foddlplbi

fpddlpmbi

fpddmqnbj

fqddmrnbj

greensock

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...