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.
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
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…
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
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.
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.
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):
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.