Search code examples
actionscript-3actionscripthtmltexttint

Can I tint a htmltext img tag in AS3?


Can I tint an image from library included in an htmlText in AS3 (using flash cs5)?

On the stage I'd use:

var cTint:Color = new Color();
cTint.setTint(0xff00ff, .25);
image.transform.colorTransform = cTint;

The htmlText code (cobj.img is a string with the library AS linkage name):

op.htmlText = "<img src='"+cobj.img+"' width='40' height='40' vspace='0' />";

And if not, is there a way to use an image from stage instead? So I can create an image, put it to stage and then in the htmlText.


Solution

  • Create an instance from the image, tint it and add that in you text! Suppose your image is a MovieClip in the library.

    var libraryImage:MovieClip = new LibraryImage();
    var cTint:Color = new Color();
    cTint.setTint(0xff00ff, .25);
    libraryImage.transform.colorTransform = cTint;
    
    op.htmlText = "<p> </p><img src='libraryImage' width='40' height='40' vspace='0' />";
    //add empty string at the start and you dont need to concatenate the string.