View Full Version : dynamic text
blindlizard
July 28th, 2003, 11:21 PM
I know very little about actionscripting, so bear with me. I have a dynamic text field (assuming it needs to be dynamic to change at run time). I want the text to be vertical (but it can because it is dynamic), so I put a return after each letter. Now I need to have the words scroll from the top of the page to the bottom, but I want the words to change as it moves. So say the text scrolled from the top to the bottom in 45 frames, I want the text to change every 5 frames or so. That would be a lot of tweening to change the text manually, so is there a way to do it with script?
lostinbeta
July 28th, 2003, 11:53 PM
I am not sure I understand you correctly, but if I do, you want something like ::shudders:: a vertical scrolling marquee ::shudders again::
Check my attachment, is that what you are talking about?
(it's a quicky to make sure we are on the same level, so excuse it's ugliness)
blindlizard
July 29th, 2003, 01:40 AM
That is exactly what I was talking about. Thank you very much! Are there some fonts that don't work in dynamic text boxes? I am trying to use a matrix style code font called mCode15 but when I change the text area to that font it just turns back into Arial at run time. I then added another dynamic text area just to see if I could type something and see it when it ran, but it came up as squares. It is weird, I can see the font fine on the stage, but if I do test movie, it won't show up.
lostinbeta
July 29th, 2003, 01:52 AM
It would be easier to set the font and such in the properties of the textbox itself. Right click on the textbox and open the properties panel, then in there select the font you want to use, and set the size as well.
Be sure that if you are using a font that not all viewers would have installed that you click on the "Character..." button and choose the embed the font outline (preferrably for all characters just to be safe).
It would be easier to do it this way because if you were to do it via actionscript you would have to import the font into the library, set it's linkage settings to export for actionscript, then call upon the font in actionscript. And sometimes it doesn't always work as peachy keen as you expect :-\
blindlizard
July 29th, 2003, 01:54 AM
You are the man, that worked GREAT!!
lostinbeta
July 29th, 2003, 01:57 AM
Glad I could help. If you don't understand anything about the script please don't hesitate to ask, I will try and see if I can explain it in further detail later.
Right now though, it is 2am and I am off to bed :)
blindlizard
July 29th, 2003, 02:02 AM
Good night!, the code is straight foward, especially with all the comments. I am a VB/VBScript/JavaScript coder coder by trade, so the code comes easy. I am trying to learn Flash on the fly here. I come up with ideas, then try to figure them out, but I stayed away from scripting (other than cut and paste from the net). Now it is time for me to dig in :)
lostinbeta
July 29th, 2003, 12:02 PM
Well I wish you luck digging into Actionscript :)
If you code in Javascript you really shouldn't have much trouble with Actionscript, knowing Javascript beforehand definitely helped speed up my learning process of Actionscript. A lot of the syntax and commands are the same between the 2 languages.
blindlizard
July 29th, 2003, 12:18 PM
Crap, another question, is it possible to make a dynamic text area a mask? I want the text to be gradient, but the only way I can do it is to make a gradient rectangle masked by the text.
lostinbeta
July 29th, 2003, 12:21 PM
Hrmm, sorry, as far as I know, dynamic textboxes cannot be used as a mask :-\
blindlizard
July 29th, 2003, 12:26 PM
hmmm, do you know if I can change the color of each letter? I tried, but when I test it, it all shows up as the first color.
lostinbeta
July 29th, 2003, 12:33 PM
There isn't really an "easy" way to create gradient text via actionscript.
It would basically involved html formatted text with the <FONT COLOR=#xxxxxx>letter</FONT>
You can HTML format a textbox like this...
textboxInstanceName.html = true
And then to tell it to read the text as HTML you will need to use..
textboxInstanceName.htmlText = whatever
(If adapting it to previously attached .fla file you will need to change .text to .htmlText in the script)
After that you can ...
A) Try to develop a script to dynamically create gradient text with the HTML font tags color attribute.
B) Use the HTML font tag with the color attribute to manually type in what you want.
blindlizard
July 29th, 2003, 12:38 PM
So in the array of words, I would have to put a font tag around each letter? So will I need to change the split for each word to put in the return ("\n"), or will it matter that it puts the html in like
<\nf\no\nn\nt\n>
lostinbeta
July 29th, 2003, 12:42 PM
You don't need to put in the return after each letter in the tag, just after the font tag itself at the very end. Your tag would basically be...
<FONT COLOR="#XXXXXX">letter</FONT>\n
blindlizard
July 29th, 2003, 12:44 PM
ok, so insted of putting the font tag around each letter in the array, I should add the font tag when the loop puts each letter into the text area.
lostinbeta
July 29th, 2003, 12:57 PM
Yeah, but that will make each letter the same color. So what you will have to do is make ANOTHER array to store the hex color codes.
Something like..
colors = ["#FFFFFF", "#FFFF00", "#FFFF99", "etc"]
And then in the for loop for the hmlText you would do this..
displayWord.htmlText += "<FONT COLOR='"+colors[l]+"'>"+chosenWord[l]+"</FONT>\n";
I didn't test it, and can't test it right now, but being a coder you should be able to take it from there.
I have to go now... gotta finish working on this PHP/mySQL thing :hangover:
blindlizard
July 29th, 2003, 04:53 PM
Ok, I have been playing around with it, and I cannot get anything to display when I use HTML formatting. Here is what my code looks like
//create array to store words
words = ["abcdefghijklmnopqrstuvwxyz", "jfhriuysdplmwnbuaqzsytcvdw", "qiplmnbvcxzasdfghjklpoiuyt", "qornvhfpdyismxznbvcwidfhgl", "qwertyuioplkjhgfdsazxcvbnm", "hjklgfdsayuioptrewqvbcnmxw"];
colors = ["#002300", "#004600", "#006000", "#00FF99", "#00FF99", "#00FF99", "#00FF99", "#00FF99", "#00FF99", "#00FF99", "#00FF99", "#00FF99", "#00FF99", "#00FF99", "#00FF99", "#00FF99", "#00FF99", "#00FF99", "#00FF99", "#00FF99", "#00FF99", "#00FF99", "#00FF99", "#00FF99", "#00FF99", "#00FF99"]
//colors = ["#00FF99", "#00FF99", "#00FF99", "#00FF99", "#00FF99", "#00FF99", "#00FF99", "#00FF99", "#00FF99", "#00FF99", "#00FF99", "#00FF99", "#00FF99", "#00FF99", "#00FF99", "#00FF99", "#00FF99", "#00FF99", "#00FF99", "#00FF99", "#00FF99", "#00FF99", "#00FF99", "#00FF99", "#00FF99", "#00FF99"]
//set textbox to be able to autosize the the text amount
displayWord.autoSize = true;
displayWord.html = true;
//create and start variable i off at 0
var i = 0;
function chooseWord() {
//clear textbox to start from scratch
displayWord.htmlText = "";
//choose new word from array and convert it to a string
//take that string and split it into individual letters
//split() automatically stores those letters in an array of their own
chosenWord = String(words[i]).split("");
//create for loop to parse the chosenWord array
for (var l = 0; l<chosenWord.length; l++) {
//print chosen word vertically
displayWord.htmlText += "<FONT COLOR=\""+colors[l]+"\">"+chosenWord[l]+"</FONT>\n";
trace("<FONT COLOR=\""+colors[l]+"\">"+chosenWord[l]+"</FONT>\n")
}
//if the variable is is greater than or equal to the length of the words array-1
//set i to be equal to 0 again
//else ++i (increment variable i by 1)
i>=words.length-1 ? i=0 : ++i;
}
//run function when frame is hit
chooseWord();
//use setInterval to run function every 1 second (1000 milliseconds)
update = setInterval(chooseWord, 500);
lostinbeta
July 29th, 2003, 04:58 PM
Uhhh, works fine for me :-\
blindlizard
July 29th, 2003, 05:05 PM
ah, it is the font.....I set it to embed all characters, and nothing shows up, but if I don't embed, then it just shows Arial. hmmm
lostinbeta
July 29th, 2003, 05:09 PM
Hmm, thats weird. I don't know whats up with that.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.