First time here? First time here? Newsletter Signup Newsletter
Search tutorials
Author: Charles Jackson | Website: http://www.hedonismgames.com

This is actually a very simple tutorial, but it took me a while to figure out because I couldn't find anything about it anywhere!

First things first, create a text box and set it anywhere on the screen. This is the only asset, so you don't need seperate layers (unless you want to keep the good habit going! You do need to name it, however. If you want to copy mine, I used the name "text". Make sure that it's set to dynamic text and the render text as html is selected (it looks like the <%lt%><%gt%> symbol, to the right of the selectable button and two left from the var: box). Without this box, all HTML code would simply appear as normal letters!

Next, open up the actions screen. This program is only four lines long; it could be one, but it's always important to make your code as easy to edit as possible! Let me explain each line here:

  1. word = "red";
  2. color = "\"#FFFF00\"";
  3. text.htmlText = "This is <%lt%>FONT COLOR="+color+"<%gt%>" +word+"<%lt%>/FONT<%gt%>.";

Line One: I created a variable simply called "word" and set it to "red". Make sure the quotes are there, or it'll try to take from a variable instead of using the text.

Line Two: Another variable - color. To render HTML colors, you need it in hexadecimal format: "#RRGGBB", quotes included. To create the quotes, use the \". That's why that looks so funky :)

Line Four: This is the code that actually does the work. First, to make it format using the html, you need to use the .htmlText instead of .text. Then, we get to <%lt%>FONT COLOR="+color+"<%gt%>". To simplify, this translates to <%lt%>FONT COLOR="#FFFF00"<%gt%>. If you've ever used HTML, you'll realize the similarities. Second, following this is +word+. This simply adds the word variable in there. Then you close the font tag (<%lt%>/FONT<%gt%>), and presto!

Now here comes the fun part: Go ahead and switch those variables up! As long as you keep the color one the same, with 6 letters/numbers 0-F, it'll work. If you want a specific color, just look online for hexadecimal color codes.

And, finally - if you still have any questions, don't hesitate to let me know!

» Level Basic

Added: 2005-02-16
Rating: 5 Votes: 1
» Author
Contract Game Developer, specialized in Flash. Still learning as I go (that's the fun!), and always glad to share what I learn.
» Download
Download the files used in this tutorial.
» Forums
More help? Search our boards for quick answers!
Featured Flash FLA
» Author: Inocreato
» Title: RaiseTheBlocks
» Description: Raise all the blocks to win the game
Featured Sound Loops
Image for equalize

Audio Player

» Author: TomCat Carty
» Title: The Wood
» Description: Just a little game ending or it can maybe be looped. Recorders with music box and percussion to give the feel of well, I don't know, the woods? Free to use, just credit me. thank you
Latest Font
» Author: Fábio FAFERS
» Description: I created this font for free use. Everyone can apply it in personal or business texts. Its free, but I want to be communicated in case of business use. Donations are accepted to keep the project of free fonts alive! Thank you all
Featured Sound Fx
Image for equalize

Audio Player

» Author: Davisigner
» Description: Hmm... what to say about this one? It's reminiscent of the closing notes of the opening music from the Three Stooges done in a church organ style with a closing cymbal crash. I'll give this one away gratis, but feel free to check out my free loops and potential upcoming license-mandated ones over in the respective part of Flashkit.