Changing color of text programmatically
Mar 04, 2015
By
Andrew Lian
Hello
I have looked for answers in the forum and the net but could not find what I was looking for. I want to change the color of a text (or use strikethrough) by embedding html commands into strings generated by javascript and sent back to the player for display in a textbox. So far, I have been able to make <b> and <i> work but I have not been able to change colors or use the <strike> command to strikethrough text.
I must be missing something. Any ideas would be welcome.
Thanks
Andrew
6 Replies
maybe using states for the strikethrough and change of color? use a trigger to change the state depending on the variable.
Another option is using a web object to draw in your variable content. With some careful templating, you could use a single web object for multiple purposes and even include things like web fonts.
I've found that Web object text looks so much nicer than the Storyline published fonts anyway.
Hmmm... thanks to both of you. That has given me something to think about. I appreciate it.
Andrew
I should have explained that I am looking at displaying parts of text (e.g. individual words) with different colours or styles in a string constructed by a Javascript script. Unfortunately, that makes life much more complicated... :(
Andrew,
When you use a Javascript string to render text in a variable embedded in a Text Box, you have only a limited sub-set of HTML that you can use if you are trying to publish to Flash. If you are publishing to HTML you have a wider range of mark-up at your disposal.
Here's a link that will give you what's available when publishing to Flash:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/text/TextField.html#htmlText
Example:
I have a text variable defined within Storyline, called theText.
I embed theText into a slide: %theText%.
I set up a trigger that fires when the timeline starts (or anywhere along the timeline):
var filler = "<span><font color='#FF0000'>Hi</font> Mark</span>";
var player = GetPlayer();
player.SetVar("theText",filler);
This renders the text wrapped by the <font> markup in red. You need to use hex numbers to describe colors to make this work for both Flash and HTML5.
HTH.
Thanks for popping in to assist Mark :)
This discussion is closed. You can start a new discussion or contact Articulate Support.