Dynamic textfield

Hello !

I have a textfield with a lenght of 248 chars.
I want to load an external file into this field and when the number of chars exceeds 248 I want it to display "… (click button x for more) " at the end of the text.

Any of you know how this works?





if you’re loading text into a dynamic textfield from an external file then you can’t put any symbols into that field as well. the button telling them to click would have to exist outside the field although you could put it on top of the field in another layer.

you could write a script that checks the char length of the text string being loaded into the text field and tell it to gotoAndStop(2) when it hits 248 … on frame 2 you would have the textfield and all your other stuff as well as the button to click for more.

what is this for? i can’t think of any use for it so i’m kinda curious :slight_smile:

I am kind of curious too. I am curious as to why you would rather have a more button than use the scrollbar component in Flash (or create your own scrollbar, which is a pain).

And what do you want the more button to do? Load the rest of the text? Or play different frame?

To play a different frame it would be something like…

	if (_root.myText.length>=248) {

Well guys,

The reason I needed this was that I am working on a site (http://www.tempus-arti.org/intro.html) in which I use fairly small textfields. The text is loaded from a mysql database. I wanted people to see the first sentences from the different texts and (a bit CNN and other large content - style sites ) if they wanted more, they could click a button and the whole text would show in the next loaded movie.

Dammit, It’s kinda hard to explain.

But anyway, I skipped the whole Idea, cause it’s kinda crappy looking.

But now I have another problem:
The text in my flash-file looks really f*cked up.
Everytime I need a sentence to start on the next line, I get a wide gap. How do I import html break - tags?
I am using flashMX. And the database spits out an URL encoded string. so something like " &var1=blablab&var2=blablab&var3=blabal…"

hope you can help.
This thing needs to be up and running by monday…aargh


Sounds like you are in a jam.

You will first have to HTML enable your dynamic text box to accept html code. For example…

text = "This is my dynamic text";
_root.myTextBox.html = true;
_root.myTextBox.htmlText = text;

Ok, so the variable text contains the text you want to show in the textbox. I didn’t add html code in it yet, because if I did, the board would convert it. You can test it out if you would like.

That should be easily adaptable to your current text area.

Now to get rid of that annoying gap. The gap happens if you hit enter in your text. To prevent the gap use a [BR] (replace [] with <>) tag between lines to prevent that other than hitting the enter button on your keyboard. So your sentence structure would look like…

This is my first line of text[BR]and this is my second line of text[BR]and this is my third line of text,etc.

this doesn’t really do the trick.

All I get now is a number instead of my text (1911). ??

Hmmm? That must be something your database is spitting out because the code I gave you has nothing to do with numbers.

the variable “text” that I gave you in my example should be changed to the variable that loads your external text of course.

loadText = new loadVars();
loadText.onLoad = function() {
	    _root.myText.html = true;
                    _root.myText.htmlText = this.myTextVariable; 

Then in your external .txt file it will be set up as myTextVariable=this is the text you write

Maybe that will help???


back again, with the same result.
it doesn’t work:

I’m gonna take this from a new angle.

When I enter my data in my form:

I’m adding some PHP:

$var = nl2br($var);
(should replace new lines with breaks…)

I’ll get back with the result…


Just for the record, the answer to your previous problem would be something like this:

myString=new String("abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef");
if (myString.length>20 ){
	var a=myString.substr(0,20 );
	a+="... click for more";
	trace (a);

You’d have to replace myString with what you get from your database.

pom :smirk:

Great code ! thanks. Clean, simple effective. nice

But I’m still stuck with my second problem.

–> When I enter data in a database via a form, and then retrieve it via php to flash, all the [br]breaks I entered (just by pressing enter or shift-enter ) in my text end up as a blank line in my textfield.

The output from my php mysql_query
looks like this (if I manually ad [br]-tags):

var1=balbalbalb[br]bakakbakba[br]balbalba &var2=lkdslkjfdsl

I load these values into the _root of my movie, so I easely know where to find them.

loadVariables(“path/getvalues.php”, _root);

then I use the code you gave me to display the vars in the dynamic textfields:

_root.textbox.html = true;
_root.textbox.htmlText = _root.var1;

and this, Flash won’t take
It would take it if the values were between “quotation marks”
How can I get the values of my vars between quotation marks?
“”"+var1+""" doesn’t work.