Google Answers Logo
View Question
 
Q: Flash - Change font size and colour dynamically ( Answered 5 out of 5 stars,   2 Comments )
Question  
Subject: Flash - Change font size and colour dynamically
Category: Computers > Graphics
Asked by: softcom-ga
List Price: $5.00
Posted: 17 Feb 2003 09:20 PST
Expires: 19 Mar 2003 09:20 PST
Question ID: 162548
I have a Flash animation that displays text in a dynamic text field
based on an ASP script.

I would like to not only pass the text to be displayed but also the
font size and colour.  So that when the Flash file loads, it will get
the Text, size and color and display it accordingly.

Any ideas?
I currently use Flash MX, but I would prefer code that would run on a
earlier version.
Answer  
Subject: Re: Flash - Change font size and colour dynamically
Answered By: skorba-ga on 21 Feb 2003 16:55 PST
Rated:5 out of 5 stars
 
Dear softcom -

Lucy for you the problem is easily solved.

From flash 5 and up swf-movies support html-formatting of text-fields.
(This you can easily verify by creating a dynamic textfield named
"test" on the stage. Remember to tick off the "HTML" option beside the
text field! Also, please create a button with this action:

on (release)
{
test = "<font color=\"#ff0000\" size=\"10\">testing</font>";
}

Export and press the button - voila, you got red text.

What remains for you to do is simply to html-format the text you send
from your server. And remember to URL-encode the values of that text!

Example:
This is how the 'testing' variable above would look when URL-encoded:
test=%3Cfont%20color%3D%22%23ff0000%22%20size%3D%2210%22%3Etesting%3C/font%3E

Here is a link to Macromedia Tech notes:
http://www.macromedia.com/support/flash/technotes.html

Here you will find more on URL-encoding and HTML-formatted text
fields.

Good luck!

Request for Answer Clarification by softcom-ga on 22 Feb 2003 13:00 PST
Will this work for an embedded fon?

Clarification of Answer by skorba-ga on 24 Feb 2003 12:56 PST
Dear Softcom -

Yes, this will work for an embedded font.

Good luck!
softcom-ga rated this answer:5 out of 5 stars
Thanks for all the help, it worked great.

Comments  
Subject: Re: Flash - Change font size and colour dynamically
From: theta-ga on 17 Feb 2003 10:41 PST
 
Hi softcom-ga,
   It appears that dynamically changing the text size and colour may
not be possible with dynaamic text fields. The following is an extract
from the chapter 9 of Macromedia's ELearning PDF Articles
(http://www.macromedia.com/desdev/education/articles/mx_elearning/mx_elearning_ch9.pdf)
:
   "... When you build dynamic text fields, you shouldhave in mind the
nature of the different strings. Are they body text? Headlines?Short,
long, or mixed?The reason that you need to ask these questions is that
you have to format the text fieldas soon as you create it. All of the
strings put in it will inherit that formatting. Whilethere is some
flexibility, as you will see, there isn't much of it. If the text
field uses Arialsize 10, all of the text dynamically added to the text
field will also be displayed in Arialsize 10. Beyond that limitation,
actually creating dynamic text is pretty easy"

I hope a Researcher is able to find you some way around this
limitation.
Best Of Luck!
Regards,
Theta-ga
:-)
Subject: Re: Flash - Change font size and colour dynamically
From: softcom-ga on 17 Feb 2003 11:25 PST
 
Hi theta-ga

Thanks for the comment.
OK, if that's the case. Can I dynamically generate a text field that
displays text passed to the Flash file with a passed color and font
size, while still having a font embedded.

What I'm trying to do is have a Title on a web page.  The title will
be either stored in a database which a user will be able to edit on a
different screen. I already have this part working.  The problem is
that I want the user to be able to specify the font size and color. 
So I thought that Flash would be the answer because I can embed a font
and have a tranparent background.

If there is another way to put the text on the screen another way, I'd
definitely be interested.

Thanks

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy