Effects on htmlText in a TextField

In Flash when you set text in a TextField object with the htmlText property, changing the alpha value no longer works. Is there a way around that?

Answers


Some confusion here.

  1. Whether alpha works or not depends on whether the text field uses device fonts, not whether it uses HTML. (Device fonts are used any time you have a dynamic/input text and you don't embed the font.)

  2. If possible, simply publish for Flash player 10, which now supports alpha for device fonts. (Note that you have to set the alpha property of the textfield or its parent - choosing a transparent color for the text itself doesn't work.)

  3. Fallback option for v8-9 is to force bitmap caching by applying a filter. For example, you could use a drop shadow with the color set to be transparent. This causes Flash to render the text field into a bitmap before drawing it to the screen, so your alpha is applied to the bitmap and everything works.

  4. For player version 7 or lower, there's no way to get alpha for device fonts. You have to either embed the font or learn to live without alpha. :D


If you find that a text field isn't responding to the alpha property, it's probably because you haven't embedded the font. Make sure that you click "Embed..." in the textfield's properties and select, say, "Basic Latin".

If you find that your htmlText formatting (e.g. <b> and <i>) aren't showing up, you must make sure that those (styled) fonts are also embedded. An easy way to do this is to create hidden or off-stage dynamic textfields with the styles you need (be sure to embed the font too!)


You can do this without embedding the font by using the blendMode, with a minor sacrifice in text appearance (I believe).

import flash.display.BlendMode;
import flash.text.TextField;
// later...
var tf:TextField = new TextField();
tf.blendMode = BlendMode.LAYER;
tf.alpha = 0.5;

Dynamic text doesn't support the alpha property (among others). I assume setting it to HTML text imposes the same limits. One way I've found around this is to contain the text field in a movie clip and set the alpha on the movie clip instead.


Need Your Help

YouTube integration in Titanium app?

titanium appcelerator

In my application I want to integrate YouTube to show videos. I want to retrieve the titles of the videos' thumbnails. I want to show thumbnails and video titles in a custom listview.

Insert table into a word document at a specific position using apache poi

java ms-word apache-poi xwpf

I am working on a project where I am trying to create an automated report generator. I need to pinpoint a couple of specific paragraphs, eliminate the tables that are already there and insert a new...