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
Re: [Flashcoders] random concatenated txt question
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
Re: [Flashcoders] random concatenated txt question
well, i have localized x in the for loop, and changed the value in the single number generator from x to singleLetter. that seems to have been a giant part of the problem. however now, the code produces one solid string. blinks out. no text, then freezes up. 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() { singleLetter = ascii[random(ascii.length)]; return singleLetter; } function random2() { yy = _root.myTxt_txt.length; for (var x:Number = 0; x yy; x++) { j = random1(); if (initialTxt == undefined) { initialTxt = ''; } initialTxt += j.toString(); } return initialTxt; } _root.onEnterFrame = function() { uu = random2(); myTxt_txt.text = uu; trace(myTxt_txt.text: +myTxt_txt.text.length) } ___ 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
RE: [Flashcoders] random concatenated txt question
You're first populating myTxt_txt with a string of 19 spaces or other character, correct? Are you certain that random2() is not appending a new string to the end of the existing one? What if trimmed it down and changed it to... function random2() { yy = _root.myTxt_txt.length; initialTxt = ; for (x = 0; x yy; x++) { j = random1(); initialTxt = j.toString(); } return initialTxt; } Sorry, if these are basic questions, just covering the bases :p ___ 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
Re: [Flashcoders] random concatenated txt question
great fix! thx guys(or gals): 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() { singleLetter = ascii[random(ascii.length)]; return singleLetter; } function random2() { yy = _root.myTxt_txt.length; initialTxt = ; for (var x:Number = 0; x yy; x++) { j = random1(); initialTxt += j.toString(); } return initialTxt; } _root.onEnterFrame = function() { uu = random2(); myTxt_txt.text = uu; } ___ 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
Re: [Flashcoders] random concatenated txt question
I think I would take the simpler route: 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 fncShuffle() { return Math.floor(Math.random()*3)-1; } _root.onEnterFrame = function() { myTxt_txt.text = ascii.sort(fncShuffle).join().substr(0, 19); }; -- Byron Barn Canfield great fix! thx guys(or gals): 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() { singleLetter = ascii[random(ascii.length)]; return singleLetter; } function random2() { yy = _root.myTxt_txt.length; initialTxt = ; for (var x:Number = 0; x yy; x++) { j = random1(); initialTxt += j.toString(); } return initialTxt; } _root.onEnterFrame = function() { uu = random2(); myTxt_txt.text = uu; } ___ 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
Re: [Flashcoders] random concatenated txt question
Does this need to be inside the loop? if (initialTxt == undefined) { initialTxt = ''; } Why not clean up the code by typing it fully to reduce or eliminate the possibility of silly errors. initialTxt is never declared. Why is this myTxt not on _root with the other one. _root.onEnterFrame = function() { uu = random2(); myTxt_txt.text = uu; trace(myTxt_txt.text: +myTxt_txt.text.length) I have a feeling that if you clean up the code, it will suddenly start to work. Ron murder design wrote: well, i have localized x in the for loop, and changed the value in the single number generator from x to singleLetter. that seems to have been a giant part of the problem. however now, the code produces one solid string. blinks out. no text, then freezes up. 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() { singleLetter = ascii[random(ascii.length)]; return singleLetter; } function random2() { yy = _root.myTxt_txt.length; for (var x:Number = 0; x yy; x++) { j = random1(); if (initialTxt == undefined) { initialTxt = ''; } initialTxt += j.toString(); } return initialTxt; } _root.onEnterFrame = function() { uu = random2(); myTxt_txt.text = uu; trace(myTxt_txt.text: +myTxt_txt.text.length) } ___ 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