Copy link to clipboard
Copied
hi, i'm looking for an answer why the static code is working, not dynamically as below.
this.mcfont1.txt.text ===> there's a dynamic text inside a movieclip
///////////
var arr = ["A", "R", "U", "S", "E", "L", "E", "K", "T", "R", "I", "K", r(), r(), r()];
function r() {
var chars = "ABCDEFGHIJKLMNOPQURSTUVWXYZ";
return chars.substr(Math.floor(Math.random() * 62), 1);
}
for (var i = 0; i < arr.length; i++) {
//this["mcfont" + i].txt.text = arr; <-----not working
this.mcfont1.txt.text = arr; <-----working
}
////////////////////////
thank you in advance
there's no mcfont0 or mcfont2 or...
use the trace function to debug.
Copy link to clipboard
Copied
there's no mcfont0 or mcfont2 or...
use the trace function to debug.
Copy link to clipboard
Copied
hahaha thanks alot ...
forgot there's no mcfont0
this["mcfont" + (i+1)].txt.text = arr;<----this worked
alert(arr);
hahahaha...
ABCDEFGHIJKLMNOPQURSTUVWXYZ<----also been corrected
thanks alot everyone!
Copy link to clipboard
Copied
you're welcome.
Copy link to clipboard
Copied
The <----- parts would break the code, but I imagine you don't really have those in there. It mostly seems to work, though I've never used function calls inside an array before.
Could it be your dyslexic code? What happens in you use * 26 instead of * 62? Also, the alphabet is wrong:
ABCDEFGHIJKLMNOPQURSTUVWXYZ
instead of:
ABCDEFGHIJKLMNOPQRSTUVWXYZ
Copy link to clipboard
Copied
Your thread title mentions "eval". There is no "eval" anywhere in your code. So I don't know what you're asking.
But, your r() function includes "U" twice, and attempts to select characters up to position 62, even though the string only has 27 characters. Assuming you just want to return random uppercase letters, the entire thing can be replaced with:
function r() {
return String.fromCharCode(65 + Math.random() * 26);
}
Copy link to clipboard
Copied
If it AS3, make sure the font is embedded.
Copy link to clipboard
Copied
by the way i'm testing this on html canvas animate cc
Copy link to clipboard
Copied
Wait... surely he's aware that his not-working code is attempting to assign to this.mcfont0.
Copy link to clipboard
Copied
That's an assumption on our part. His example of mcfont1 working does suggest that possibility, but maybe he does have an mcfont0 on his stage.
Copy link to clipboard
Copied
this seems running fine
////////////////////////////////
function r() {
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
return chars.substr(Math.floor(Math.random() * 26), 1);
//return String.chars(65 + Math.random() * 26);
}
var arr = ["A", "R", "U", "S", "E", "L", "E", "K", "T", "R", "I", "K", r(), r(), r()];
alert("this is shit" + arr);
//alert(arr.length)
for (var i = 0; i < arr.length; i++) {
this["mcfont" + (i+1)].txt.text = arr;
alert(arr);
//this.mcfont1.txt.text = arr;
}
/////////////
Find more inspiration, events, and resources on the new Adobe Community
Explore Now