you might have an issue with using x as a global variable?   try defining 
x with "var" in the for loop.. or somewhere in the function.   if you do 
not use var, it should become a global variable.


-mike




"Byron Canfield" <[EMAIL PROTECTED]> 
Sent by: [EMAIL PROTECTED]
03/06/2006 01:55 PM
Please respond to
Flashcoders mailing list <flashcoders@chattyfig.figleaf.com>


To
flashcoders@chattyfig.figleaf.com
cc

Subject
Re: [Flashcoders] random concatenated txt question






I don't see anything there in that code that limits the string length to
19, nor anything to reset the string to a null value upon reaching the 19.

It just keeps on concatenating onto the end of the string, but you can't
see it because of the limited size of the textfield.

Try putting a trace in your onEnterFrame() and you'll see what I mean:

_root.onEnterFrame = function() {
                 myTxt_txt.text = random2();
                 trace("myTxt_txt.text: "+myTxt_txt.text.length)
};

That said, it seems to me that you're really going about this the hard
way. Each of those single-letter strings is possible to represent with a
numeric ascii value, such that there is no need for the array -- just
convert the chosen numeric value to a character at the time it is
concatenated.

-- 
Byron "Barn" Canfield


> this fills up my dynamic txt field. then just stops. it should keep
> producing a random string of 19 characters (the length of the txt 
field),
> then replace it every frame with a new string of random characters.
> instead
> it just fills up, then stops. ugh!
> ---------
>
>
>
> ascii = new Array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j",
>       "k", "l", "m", "n", "o", "p", "q", "r", "s", "t",
>       "u", "v", "w", "x", "y", "z");
>
> function random1() {
>  x = ascii[random(ascii.length)];
>  return x;
> }
>
> function random2() {
>  yy = _root.myTxt_txt.length;
>  for (x = 0; x < yy; x++) {
>   j = random1();
>   if (initialTxt == undefined) {
>    initialTxt = '';
>   }
>   initialTxt += j.toString();
>  }
>  return initialTxt;
> }
>
> _root.onEnterFrame = function() {
>  myTxt_txt.text = random2();
> }
> _______________________________________________
> Flashcoders@chattyfig.figleaf.com
> To change your subscription options or search the archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
> Brought to you by Fig Leaf Software
> Premier Authorized Adobe Consulting and Training
> http://www.figleaf.com
> http://training.figleaf.com
>


_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to